public async Task <IActionResult> Deposit( Guid userId, [FromBody][Required] WalletDepositDto wallet) { await _walletService.Deposit(userId, wallet); return(NoContent()); }
public async Task Deposit(Guid userId, WalletDepositDto walletDto) { await CheckUserExists(userId); Wallet wallet = await CreateWalletIfNotExist(userId, walletDto.Currency); if (!TryAddAmount(wallet.Total, walletDto.Amount, out decimal newTotal, out string error)) { throw new InvalidRequestException(error); } wallet.Total = newTotal; await _db.SaveChangesAsync(); }