예제 #1
0
        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);
        }
예제 #2
0
 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)));
 }
예제 #3
0
파일: History.cs 프로젝트: Gparquet/bworld
        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);
        }
예제 #4
0
 public async Task AddAsync(History history) =>
 await historyService.AddAsync(history);