2021-12-10 03:04:48 +03:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Transactions;
|
|
|
|
|
using BlueWest.Collections;
|
|
|
|
|
using MapTo;
|
|
|
|
|
using MessagePack;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using BlueWest.Collections;
|
|
|
|
|
|
|
|
|
|
namespace BlueWest.Data
|
|
|
|
|
{
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
[UseUpdate]
|
|
|
|
|
[MapFrom(typeof(UserUpdateDto))]
|
|
|
|
|
public partial class User
|
|
|
|
|
{
|
2022-08-01 00:09:39 +03:00
|
|
|
|
[Key(1)] public TimeSpan Id { get; }
|
2021-12-10 03:04:48 +03:00
|
|
|
|
[Key(2)] public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
|
2021-12-26 20:43:27 +03:00
|
|
|
|
[Key(8)] public FastDictionary<int, FinanceTransaction> FinanceTransactions { get; }
|
2021-12-10 03:04:48 +03:00
|
|
|
|
|
2022-08-01 00:09:39 +03:00
|
|
|
|
public User(TimeSpan id, string name, string address, string btcAddress, string ltcAddress, double btcAmount, double ltcAmount, FastDictionary<int, FinanceTransaction> financeTransactions)
|
2021-12-10 03:04:48 +03:00
|
|
|
|
{
|
|
|
|
|
Id = id;
|
|
|
|
|
Name = name;
|
|
|
|
|
FinanceTransactions = financeTransactions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddTransaction(FinanceTransaction financeTransaction)
|
|
|
|
|
{
|
2021-12-26 20:43:27 +03:00
|
|
|
|
FinanceTransactions.Add(FinanceTransactions.Count + 1, financeTransaction);
|
2021-12-10 03:04:48 +03:00
|
|
|
|
}
|
|
|
|
|
public void AddTransaction(FinanceTransactionInsertDto financeTransaction)
|
|
|
|
|
{
|
2022-08-01 00:09:39 +03:00
|
|
|
|
FinanceTransactions.Add(FinanceTransactions.Count + 1,
|
|
|
|
|
new FinanceTransaction(financeTransaction, TimeSpan.FromTicks(DateTime.Now.Ticks), Id));
|
2021-12-10 03:04:48 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal bool HasTransaction(int transactionId)
|
|
|
|
|
{
|
|
|
|
|
return FinanceTransactions.Contains(transactionId);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-26 20:43:27 +03:00
|
|
|
|
internal FinanceTransaction GetTransactionById(int transactionId)
|
2021-12-10 03:04:48 +03:00
|
|
|
|
{
|
2021-12-26 20:43:27 +03:00
|
|
|
|
return FinanceTransactions[transactionId];
|
2021-12-10 03:04:48 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|