public async Task <int> AccountDeposit(AccountDepositModel accountDepositModel) { //call application command to create the deposit transaction and return the tranid generated await _accountDeposit.Execute(accountDepositModel); return(accountDepositModel.TranId); }
public async Task <IActionResult> Deposit(int id, [FromBody] AccountDepositModel body) { var grain = this.client.GetGrain <IAccountGrain>(id); var response = await grain.Deposit(body.Amount); if (response.ErrorCode != ErrorCode.None) { return(BadRequest(response.ErrorMessage)); } return(Ok(response.Value)); }
public async Task <AccountDepositResults> Handle(AccountDepositCommand command, CancellationToken cancellationToken) { try { _logger.LogInformation("Deposit transaction process started."); //check account BalanceInquiryModel acctBalance = new BalanceInquiryModel(); acctBalance = await _accountService.BalanceInquiry(command.AcctId); if (acctBalance == null) { return(new AccountDepositResults { StatusCode = Convert.ToInt32(HttpStatusCode.OK), Message = Convert.ToString(HttpStatusCode.OK), MessageDetails = ManageAccountStatus.InvalidAccountNumber }); } AccountDepositModel acctDeposit = new AccountDepositModel(); acctDeposit.AcctId = command.AcctId; acctDeposit.TransactionType = command.TransactionType; acctDeposit.TransactionAmount = command.TransactionAmount; await _accountService.AccountDeposit(acctDeposit); return(new AccountDepositResults { StatusCode = Convert.ToInt32(HttpStatusCode.OK), Message = Convert.ToString(HttpStatusCode.OK), MessageDetails = ManageAccountStatus.DepositSuccess, TranId = acctDeposit.TranId }); } catch (Exception ex) { _logger.LogError("Error saving deposit transaction : {ExceptionMessage}", ex.ToString()); return(new AccountDepositResults { StatusCode = Convert.ToInt32(HttpStatusCode.InternalServerError), Message = Convert.ToString(HttpStatusCode.InternalServerError), MessageDetails = ManageAccountStatus.DepositFailed }); } }