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
|
|
|
|
|
{
|
|
|
|
|
[Key(1)] public int Id { get; }
|
|
|
|
|
[Key(2)] public string Name { get; set; }
|
|
|
|
|
[Key(3)] public string Address { get; set; }
|
|
|
|
|
|
|
|
|
|
[Key(4)] public string BTCAddress { get; set; }
|
|
|
|
|
[Key(5)] public string LTCAddress { get; set; }
|
|
|
|
|
|
|
|
|
|
[Key(6)] public double BTCAmount { get; set; }
|
|
|
|
|
[Key(7)] public double LTCAmount { 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
|
|
|
|
|
2021-12-26 20:43:27 +03:00
|
|
|
|
public User(int 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;
|
|
|
|
|
Address = address;
|
|
|
|
|
BTCAddress = btcAddress;
|
|
|
|
|
LTCAddress = ltcAddress;
|
|
|
|
|
BTCAmount = btcAmount;
|
|
|
|
|
LTCAmount = ltcAmount;
|
|
|
|
|
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)
|
|
|
|
|
{
|
2021-12-26 20:43:27 +03:00
|
|
|
|
FinanceTransactions.Add(FinanceTransactions.Count + 1, new FinanceTransaction(financeTransaction, FinanceTransactions.Count + 1));
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|