/// <summary> /// Метод добавляет новую транзакцию /// </summary> /// <param name="transaction">Транзакция</param> /// <param name="userId">Идентификатор отправителя</param> /// <returns>IActionResult</returns> public async Task <IActionResult> CreateTransaction(TransactionAddViewModel transaction, string userId) { try { if (!transaction.ValidateModel(out string error)) { return(Helper.SetObjectResultStatus(error, 400)); } var rezultSave = await _transactionService.CreateTransaction( new TransactionAddDto() { RecepientId = transaction.RecepientId, Value = transaction.Value, UserId = userId }, _balanceService); return(rezultSave.Item1 ? Helper.SetObjectResultStatus(rezultSave.Item3.ToString()) : Helper.SetObjectResultStatus(rezultSave.Item2, rezultSave.Item3)); } catch (Exception e) { _iLogger.LogError(e.ToString()); return(Helper.SetObjectResultStatus(e.ToString(), 500)); } }
public async Task <IActionResult> CreateTransaction([FromBody] TransactionAddViewModel transaction) { string userId = User.Claims.First(c => c.Type == "UserId").Value; return(await _BalancesControllerProxy.CreateTransaction(transaction, userId)); }