public async Task <bool> SaveBankAccount(BankAccountVM bankAccountVM) { try { var bankAccount = MapToDBModel(bankAccountVM); if (bankAccount == null) { return(false); } return(await _bankAccountService.SaveBankAccount(bankAccount)); } catch (Exception) { //Error handle return(false); } }
private BankAccount MapToDBModel(BankAccountVM bankAccountVM) { try { return(new BankAccount() { ID = !string.IsNullOrEmpty(bankAccountVM.ID) ? int.Parse(bankAccountVM.ID) : 0, UserID = bankAccountVM.UserID, CompanyID = bankAccountVM.CompanyID, BankName = bankAccountVM.BankName, BankBranch = bankAccountVM.BankBranch, AccountNumber = bankAccountVM.AccountNumber }); } catch (Exception) { //Error handle return(null); } }
public async Task <IActionResult> SaveBankAccount(string userId, [FromBody] BankAccountVM bankAccount) { try { if (userId != bankAccount.UserID || _jwtHelper.GetUserId() != userId || !ModelState.IsValid) { return(BadRequest()); } var saveResponse = await _bankAccountMap.SaveBankAccount(bankAccount); if (saveResponse) { return(NoContent()); } } catch (Exception) { //Error handle } return(StatusCode(500)); }
protected override void InsertNew() { EditVM = new BankAccountVM(); IsInEditMode = true; }