示例#1
0
        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 ?? ""}"));
            }
        }
示例#2
0
        //Add
        public IActionResult AddWithdrawal(AccountWithdrawCrudModel model)
        {
            var response = _accountCore.Withdraw(model);

            return(Json(response));
        }