public async Task <Guid> UpdateBankAccountAsync(Guid Id, BankAccountRequestDTO requestDTO) { var currentBankAccount = await _repository.GetByIdAsync <Domain.Model.Account.BankAccount>(Id); if (currentBankAccount == null) { return(Guid.Empty); } currentBankAccount.AccountIBAN = requestDTO.AccountIBAN; currentBankAccount.AccountNo = requestDTO.AccountNo; currentBankAccount.AccountType = requestDTO.AccountType; currentBankAccount.BankAccountDescription = requestDTO.BankAccountDescription; currentBankAccount.BankAccountName = requestDTO.BankAccountName; currentBankAccount.BankType = requestDTO.BankType; currentBankAccount.BlockedBalance = requestDTO.BlockedBalance; currentBankAccount.CurrencyType = requestDTO.CurrencyType; currentBankAccount.TotalBalance = requestDTO.TotalBalance; currentBankAccount.UsableBalance = requestDTO.UsableBalance; _repository.Update(currentBankAccount); await _repository.CommitAsync(); return(currentBankAccount.Id); }
public async Task <Guid> CreateNewBankAccountAsync(BankAccountRequestDTO requestDTO) { Domain.Model.Institution.Institution currentInstitution; if (string.IsNullOrEmpty(CurrentInstitutionId)) {//admin user so , ins id will come from request payload. currentInstitution = await _repository.GetByIdAsync <Domain.Model.Institution.Institution>(requestDTO.InstitutionId.Value); } else {//casual user. currentInstitution = await _repository.GetByIdAsync <Domain.Model.Institution.Institution>(Guid.Parse(CurrentInstitutionId)); } if (currentInstitution == null) { return(Guid.Empty); } var newInstance = new Domain.Model.Account.BankAccount { BankAccountName = requestDTO.BankAccountName, Institution = currentInstitution, AccountIBAN = requestDTO.AccountIBAN, AccountNo = requestDTO.AccountNo, AccountType = requestDTO.AccountType, BankAccountDescription = requestDTO.BankAccountDescription, BankType = requestDTO.BankType, BlockedBalance = requestDTO.BlockedBalance, CurrencyType = requestDTO.CurrencyType, TotalBalance = requestDTO.TotalBalance, UsableBalance = requestDTO.UsableBalance }; _repository.Add(newInstance); await _repository.CommitAsync(); return(newInstance.Id); }
public async Task <IActionResult> CreateBankAccount([FromBody] BankAccountRequestDTO requestDTO) { var result = await _bankAccountService.CreateNewBankAccountAsync(requestDTO); return(new OkObjectResult(new { Id = result })); }
public async Task <IActionResult> UpdateBankAccount(Guid Id, [FromBody] BankAccountRequestDTO requestDTO) { var result = await _bankAccountService.UpdateBankAccountAsync(Id, requestDTO); return(new OkObjectResult(new { Id = result })); }