public async Task HandlerAsync(FastSell command) { await _transactionService.FastSellTransactionAsync(command.FromCurrency, command.Amount, command.UserId); var price = await CryptoCompare.GetCryptoPriceInUsd(command.FromCurrency); await _historyService.AddAsync(OperationType.Sell, command.FromCurrency, command.Amount, price, command.UserId); }
public async Task <IActionResult> AddItemInHistory([FromBody] HistoryItem historyItem) { if (historyItem == null) { return(BadRequest($"Parameter is not defined in query {nameof(historyItem)}")); } return(Ok(await _historyService.AddAsync(historyItem))); }
public async System.Threading.Tasks.Task SaveAsync(string content, string id, string userId, CheckPointType checkPointType) { var history = await _historyService.GetHistoryAsync(id); var jsonDiffPatch = new JsonDiffPatch(); var left = JToken.Parse("{}"); if (history == null) { history = new HistoryDbModel() { CheckPoints = new List <CheckPoint>(), ElementId = id, }; } else { foreach (var checkpoint in history.CheckPoints) { var patch = JToken.Parse(checkpoint.Patch); left = jsonDiffPatch.Patch(left, patch); } } var checkPoint = new CheckPoint() { Id = Guid.NewGuid().ToString(), UserId = userId, CheckPointType = checkPointType, Hash = Hash(content) }; var lastRight = JToken.Parse(content); checkPoint.Patch = jsonDiffPatch.Diff(left, lastRight).ToString(); await _historyService.AddAsync(id, checkPoint); }
public async Task AddAsync(History history) => await historyService.AddAsync(history);