From 928137460ed78d48fe985763351030d43803f109 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Wed, 17 May 2023 20:00:17 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=D0=B0?= =?UTF-8?q?=20"=D0=9E=D1=82=D0=BA=D0=BB=D0=BE=D0=BD=D0=B5=D0=BD=D0=BE".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/AccountLogic.cs | 2 +- .../BusinessLogics/CashWithdrawalLogic.cs | 25 ++++++++++++++----- .../Views/Home/Enter.cshtml | 4 +-- .../Views/Home/Index.cshtml | 2 +- .../ICashWithdrawalLogic.cs | 2 +- .../Enums/StatusEnum.cs | 4 ++- .../Controllers/AccountController.cs | 25 +++++++++++++------ 7 files changed, 45 insertions(+), 19 deletions(-) diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs index 61b512e..762acf3 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs @@ -79,7 +79,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics //проверяем возможность операции снятия (sum может быть отрицательной) if (sum + account.Balance < 0) { - throw new ArgumentNullException("Операция невозможна. Недостаточно средств", nameof(account)); + return false; } //обновляем балланс счёта diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CashWithdrawalLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CashWithdrawalLogic.cs index dd071bc..1a61cdd 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CashWithdrawalLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CashWithdrawalLogic.cs @@ -71,7 +71,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics return list; } - public bool Create(CashWithdrawalBindingModel model) + public bool Create(CashWithdrawalBindingModel model, bool flag) { CheckModel(model); @@ -82,12 +82,25 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics return false; } - _debitingStorage.Update(new DebitingBindingModel + if (flag) { - Id = model.DebitingId, - DateClose = DateTime.Now, - Status = StatusEnum.Закрыта - }); + _debitingStorage.Update(new DebitingBindingModel + { + Id = model.DebitingId, + DateClose = DateTime.Now, + Status = StatusEnum.Закрыта + }); + } + else + { + _debitingStorage.Update(new DebitingBindingModel + { + Id = model.DebitingId, + DateClose = DateTime.Now, + Status = StatusEnum.Отклонено + }); + } + return true; } diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Enter.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Enter.cshtml index 8e277d4..82f8a43 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Enter.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Enter.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "Enter"; + ViewData["Title"] = "Вход"; }
@@ -9,7 +9,7 @@
Логин:
-
diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml index 346b10c..bbaf558 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml @@ -3,7 +3,7 @@ @model List @{ - ViewData["Title"] = "Home Page"; + ViewData["Title"] = "Cписок счетов"; }
diff --git a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/ICashWithdrawalLogic.cs b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/ICashWithdrawalLogic.cs index 93841c2..4c4ab60 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/ICashWithdrawalLogic.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/ICashWithdrawalLogic.cs @@ -15,7 +15,7 @@ namespace BankYouBankruptContracts.BusinessLogicsContracts CashWithdrawalViewModel? ReadElement(CashWithdrawalSearchModel model); - bool Create(CashWithdrawalBindingModel model); + bool Create(CashWithdrawalBindingModel model, bool flag); bool Update(CashWithdrawalBindingModel model); diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Enums/StatusEnum.cs b/BankYouBankrupt/BankYouBankruptDataModels/Enums/StatusEnum.cs index 285fab6..d60a177 100644 --- a/BankYouBankrupt/BankYouBankruptDataModels/Enums/StatusEnum.cs +++ b/BankYouBankrupt/BankYouBankruptDataModels/Enums/StatusEnum.cs @@ -10,6 +10,8 @@ namespace BankYouBankruptDataModels.Enums { Открыта = 0, - Закрыта = 1 + Закрыта = 1, + + Отклонено = 2 } } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs index 90987d4..7b9ea33 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs @@ -180,12 +180,13 @@ namespace BankYouBankruptRestApi.Controllers { try { - _cashLogic.Create(CashWithdrawal); - _accountLogic.ChangeBalance(new AccountSearchModel + bool flag =_accountLogic.ChangeBalance(new AccountSearchModel { Id = CashWithdrawal.AccountId }, CashWithdrawal.Sum * -1); + + _cashLogic.Create(CashWithdrawal, flag); } catch (Exception ex) { @@ -194,7 +195,7 @@ namespace BankYouBankruptRestApi.Controllers } } - //подтверждение заявки на снятие средств со счёта + //подтверждение заявки на перевод либо пополнение балланса [HttpPost] public void CloseCrediting(MoneyTransferBindingModel moneyTransfer) { @@ -202,19 +203,29 @@ namespace BankYouBankruptRestApi.Controllers { _moneyTransferLogic.Create(moneyTransfer); + bool flag = true; + //если нет отправителя, т. е. операция на перевод денег из нала в виртуал на карту if (moneyTransfer.AccountSenderId.HasValue) { - _accountLogic.ChangeBalance(new AccountSearchModel + flag = _accountLogic.ChangeBalance(new AccountSearchModel { Id = moneyTransfer.AccountSenderId }, moneyTransfer.Sum * -1); } - _accountLogic.ChangeBalance(new AccountSearchModel + if (flag) { - Id = moneyTransfer.AccountPayeeId - }, moneyTransfer.Sum); + _accountLogic.ChangeBalance(new AccountSearchModel + { + Id = moneyTransfer.AccountPayeeId + }, moneyTransfer.Sum); + } + else + { + throw new Exception("Недостаточно средств"); + } + } catch (Exception ex) {