working state
This commit is contained in:
parent
f999e96b6f
commit
de94c8671c
|
@ -4,48 +4,33 @@ using MessagePack;
|
|||
|
||||
namespace BlueWest.Data
|
||||
{
|
||||
public enum FinanceSymbol
|
||||
{
|
||||
BTC_EUR,
|
||||
BTC_BUSD,
|
||||
BTC_USD,
|
||||
BTC_USDT,
|
||||
LTC_EUR,
|
||||
LTC_BUSD,
|
||||
LTC_USDT
|
||||
}
|
||||
|
||||
public enum FinanceTransactionType
|
||||
{
|
||||
Buy,
|
||||
Sell
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
[MapFrom(typeof(FinanceTransactionInsertDto))]
|
||||
public partial struct FinanceTransaction
|
||||
{
|
||||
[Key(1)] public int Id { get; set; }
|
||||
[Key(2)] public int UserId { get; set; }
|
||||
[Key(3)] public FinanceTransactionType FinanceTransactionType { get; }
|
||||
[Key(4)] public FinanceSymbol FinanceSymbol { get; }
|
||||
[Key(1)] public TimeSpan CreationDate { get; set; }
|
||||
[Key(2)] public TimeSpan UserId { get; set; }
|
||||
|
||||
[Key(4)] public string Currency { get; }
|
||||
[Key(5)] public double Amount { get; } // To Buy
|
||||
[Key(6)] public double Quantity { get; } // Bought
|
||||
[Key(7)] public double Fee { get; }
|
||||
[Key(8)] public DateTime DateTime { get; }
|
||||
[Key(8)] public TimeSpan UploadedDate { get; }
|
||||
[Key(9)] public TimeSpan TransactionDate { get; }
|
||||
|
||||
|
||||
public FinanceTransaction(int id, int userId, FinanceTransactionType financeTransactionType,
|
||||
FinanceSymbol financeSymbol, double amount, double quantity, double fee, DateTime dateTime)
|
||||
public FinanceTransaction(TimeSpan creationDate, TimeSpan userId,
|
||||
string currency, double amount, double quantity, double fee, TimeSpan uploadedDate, TimeSpan transactionDate)
|
||||
{
|
||||
Id = id;
|
||||
CreationDate = creationDate;
|
||||
UserId = userId;
|
||||
FinanceTransactionType = financeTransactionType;
|
||||
FinanceSymbol = financeSymbol;
|
||||
Amount = amount;
|
||||
Quantity = quantity;
|
||||
Fee = fee;
|
||||
DateTime = dateTime;
|
||||
Currency = currency;
|
||||
UploadedDate = uploadedDate;
|
||||
TransactionDate = transactionDate;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,30 +9,29 @@ namespace BlueWest.Data
|
|||
|
||||
public partial struct FinanceTransactionInsertDto
|
||||
{
|
||||
public int UserId { get; }
|
||||
public FinanceTransactionType FinanceTransactionType { get; }
|
||||
public FinanceSymbol FinanceSymbol { get; }
|
||||
public string Currency { get; }
|
||||
public double Amount { get; } // To Buy
|
||||
public double Quantity { get; } // Bought
|
||||
public double Fee { get; }
|
||||
public DateTime DateTime { get; }
|
||||
public TimeSpan UploadedDate { get; }
|
||||
public TimeSpan TransactionDate { get; }
|
||||
|
||||
|
||||
|
||||
public FinanceTransactionInsertDto(
|
||||
int userId,
|
||||
FinanceTransactionType financeTransactionType,
|
||||
FinanceSymbol financeSymbol,
|
||||
string currency,
|
||||
double amount ,
|
||||
double quantity,
|
||||
double fee,
|
||||
DateTime dateTime)
|
||||
TimeSpan uploadedDate,
|
||||
TimeSpan transactionDate)
|
||||
{
|
||||
UserId = userId;
|
||||
FinanceTransactionType = financeTransactionType;
|
||||
FinanceSymbol = financeSymbol;
|
||||
Currency = currency;
|
||||
Amount = amount;
|
||||
Quantity = quantity;
|
||||
Fee = fee;
|
||||
DateTime = dateTime;
|
||||
UploadedDate = uploadedDate;
|
||||
TransactionDate = transactionDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,14 @@ namespace BlueWest.Data
|
|||
|
||||
public partial struct FinanceTransactionReadDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public FinanceTransactionType FinanceTransactionType { get; }
|
||||
public FinanceSymbol FinanceSymbol { get; }
|
||||
public TimeSpan CreationDate { get; set; }
|
||||
public TimeSpan UserId { get; set; }
|
||||
|
||||
public string Currency { get; }
|
||||
public double Amount { get; } // To Buy
|
||||
public double Quantity { get; } // Bought
|
||||
public double Fee { get; }
|
||||
public DateTime DateTime { get; }
|
||||
public TimeSpan UploadedDate { get; }
|
||||
public TimeSpan TransactionDate { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,27 +15,16 @@ namespace BlueWest.Data
|
|||
[MapFrom(typeof(UserUpdateDto))]
|
||||
public partial class User
|
||||
{
|
||||
[Key(1)] public int Id { get; }
|
||||
[Key(1)] public TimeSpan 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; }
|
||||
|
||||
[Key(8)] public FastDictionary<int, FinanceTransaction> FinanceTransactions { get; }
|
||||
|
||||
public User(int id, string name, string address, string btcAddress, string ltcAddress, double btcAmount, double ltcAmount, FastDictionary<int, FinanceTransaction> financeTransactions)
|
||||
public User(TimeSpan id, string name, string address, string btcAddress, string ltcAddress, double btcAmount, double ltcAmount, FastDictionary<int, FinanceTransaction> financeTransactions)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Address = address;
|
||||
BTCAddress = btcAddress;
|
||||
LTCAddress = ltcAddress;
|
||||
BTCAmount = btcAmount;
|
||||
LTCAmount = ltcAmount;
|
||||
FinanceTransactions = financeTransactions;
|
||||
}
|
||||
|
||||
|
@ -45,7 +34,8 @@ namespace BlueWest.Data
|
|||
}
|
||||
public void AddTransaction(FinanceTransactionInsertDto financeTransaction)
|
||||
{
|
||||
FinanceTransactions.Add(FinanceTransactions.Count + 1, new FinanceTransaction(financeTransaction, FinanceTransactions.Count + 1));
|
||||
FinanceTransactions.Add(FinanceTransactions.Count + 1,
|
||||
new FinanceTransaction(financeTransaction, TimeSpan.FromTicks(DateTime.Now.Ticks), Id));
|
||||
}
|
||||
|
||||
internal bool HasTransaction(int transactionId)
|
||||
|
|
|
@ -7,15 +7,5 @@ namespace BlueWest.Data
|
|||
public partial struct UserUpdateDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Address { get; set; }
|
||||
|
||||
public string BTCAddress { get; set; }
|
||||
public string LTCAddress { get; set; }
|
||||
|
||||
public double BTCAmount { get; set; }
|
||||
public double LTCAmount { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Transactions;
|
||||
using BlueWest.Collections;
|
||||
|
@ -100,7 +101,8 @@ namespace BlueWest.Data
|
|||
{
|
||||
if (Users.ContainsKey(userId))
|
||||
{
|
||||
var financeTransaction = new FinanceTransaction(financeTransactionDto, Users[userId].FinanceTransactions.Count + 1);
|
||||
var now = TimeSpan.FromTicks(DateTime.Now.Ticks);
|
||||
var financeTransaction = new FinanceTransaction(financeTransactionDto, now, Users[userId].Id);
|
||||
Users[userId].AddTransaction(financeTransaction);
|
||||
return new DataQueryResult<FinanceTransaction>(financeTransaction);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Immutable;
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using BlueWest.Collections;
|
||||
using BlueWest.Data;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
@ -57,7 +58,7 @@ namespace BlueWest.WebApi.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[HttpGet("{userId}/transactions/{transactionId}")]
|
||||
public ActionResult GetTransactionsById(int userId, int transactionId)
|
||||
public ActionResult GetTransactionsById(int userId, TimeSpan transactionId)
|
||||
{
|
||||
var user = MemoryData.UserList.GetUserById(userId);
|
||||
|
||||
|
@ -65,7 +66,7 @@ namespace BlueWest.WebApi.Controllers
|
|||
|
||||
var transactions = user?.Value.FinanceTransactions;
|
||||
|
||||
FinanceTransaction? transaction = transactions?.Values.ToImmutableArray().FirstOrNull(t => t.Id == transactionId);
|
||||
FinanceTransaction? transaction = transactions?.Values.ToImmutableArray().FirstOrNull(t => t.CreationDate == transactionId);
|
||||
|
||||
if (transaction != null)
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace BlueWest.Core
|
|||
{
|
||||
//Console.WriteLine(Time.time);
|
||||
}
|
||||
else if (input == "user")
|
||||
else if (input == "user" || input == "users")
|
||||
{
|
||||
_eventManager.TriggerEvent(new CommandRequestEvent(CommandRequestEventType.GetUsers));
|
||||
//Console.WriteLine(Time.time);
|
||||
|
|
|
@ -4,7 +4,7 @@ using BlueWest.Core.ComponentSystem;
|
|||
|
||||
namespace BlueWest.Artefacts
|
||||
{
|
||||
public class WorldArtefact: Artefact
|
||||
/*public class WorldArtefact: Artefact
|
||||
{
|
||||
|
||||
public WorldArtefact()
|
||||
|
@ -33,5 +33,5 @@ namespace BlueWest.Artefacts
|
|||
{
|
||||
base.OnDisable();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Transactions;
|
||||
using BlueWest.Collections;
|
||||
using BlueWest.Data;
|
||||
using PerformanceSolution.Tools;
|
||||
|
@ -14,6 +12,8 @@ namespace PerformanceSolution.Data
|
|||
|
||||
private const string SavePathName = "userData";
|
||||
|
||||
public static TimeSpan DateKey = new TimeSpan(2386, 0,0,0,0 );
|
||||
|
||||
private static bool DEBUG = true;
|
||||
|
||||
static MemoryData()
|
||||
|
@ -55,12 +55,13 @@ namespace PerformanceSolution.Data
|
|||
|
||||
|
||||
var transactions = new FastDictionary<int, FinanceTransaction>();
|
||||
var financeTransaction = new FinanceTransaction(0, 1, FinanceTransactionType.Buy, FinanceSymbol.BTC_EUR, 0,
|
||||
0, 0.1, DateTime.Now);
|
||||
|
||||
var u = new User(DateTime.Now.TimeOfDay, "Rui Sousa", "Sagres", "NOADD", "NOADD", 0, 0, transactions);
|
||||
var list = new FastDictionary<int, User>(10);
|
||||
var financeTransaction = new FinanceTransaction(TimeSpan.FromTicks(DateTime.Now.Ticks), u.Id, "", 0.00, 0.00, 0.00,
|
||||
TimeSpan.FromTicks(DateTime.Now.Ticks), TimeSpan.FromTicks(DateTime.Now.Ticks));
|
||||
transactions.Add(1, financeTransaction);
|
||||
|
||||
var u = new User(1, "Rui Sousa", "Sagres", "NOADD", "NOADD", 0, 0, transactions);
|
||||
var list = new FastDictionary<int, User>(10);
|
||||
list.Add(0, u);
|
||||
|
||||
return new UserList(list);
|
||||
|
|
Loading…
Reference in New Issue