public DbResponse <AccountWithdrawCrudModel> Withdraw(AccountWithdrawCrudModel model) { try { if (model.WithdrawAmount < 0) { return(new DbResponse <AccountWithdrawCrudModel>(false, "Invalid Data")); } if (_db.Account.IsNull(model.AccountId)) { return(new DbResponse <AccountWithdrawCrudModel>(false, $"Account Not Found")); } _db.Account.BalanceSubtract(model.AccountId, model.WithdrawAmount); return(_db.AccountWithdraw.Add(model)); } catch (Exception e) { return(new DbResponse <AccountWithdrawCrudModel>(false, $"{e.Message}. {e.InnerException?.Message ?? ""}")); } }
//Add public IActionResult AddWithdrawal(AccountWithdrawCrudModel model) { var response = _accountCore.Withdraw(model); return(Json(response)); }