diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/MoneyTransferLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/MoneyTransferLogic.cs index e481ac1..8493244 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/MoneyTransferLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/MoneyTransferLogic.cs @@ -82,17 +82,17 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics return false; } - if (!model.CreditingId.HasValue) + //проверка на то, что это зачисление на карту, а не перевод между счетами + if (model.CreditingId.HasValue) { - throw new Exception(); - } + _creditingStorage.Update(new CreditingBindingModel + { + Id = model.CreditingId.Value, + DateClose = DateTime.Now, + Status = StatusEnum.Закрыта + }); - _creditingStorage.Update(new CreditingBindingModel - { - Id = model.CreditingId.Value, - DateClose = DateTime.Now, - Status = StatusEnum.Закрыта - }); + } return true; } diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs index 1291dcc..206ff52 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs @@ -148,16 +148,21 @@ namespace BankYouBankruptCashierApp.Controllers //открытие счёта. Получаем и передаём список изделий во вьюху? [HttpGet] - public IActionResult Create() + public IActionResult CreateAccount() { - ViewBag.Clients = APICashier.GetRequest>("/api/Client/GetAllClients"); + //запрашиваем список в формате вспомогательной вьюшки из-за работы select в asp net + ViewBag.Clients = APICashier.GetRequest>($"/api/Client/GetAllClients").Select(x => new ClientSelectViewModel + { + Id = x.Id, + FullName = x.Surname + " " + x.Name + " " + x.Patronymic + }).ToList(); - return View(); - } + return View(); + } //создание заказа Post-запросом [HttpPost] - public void Create(int clientId, string accountNumber, string password, int balance) + public void CreateAccount(int clientId, string accountNumber, string password, int balance) { if (APICashier.Cashier == null) { @@ -249,30 +254,20 @@ namespace BankYouBankruptCashierApp.Controllers return View(APICashier.GetRequest>($"/api/Account/FindOpenCrediting")); } - //для страницы "Переводы" - [HttpGet] - public IActionResult MoneyTransfers() - { - if (APICashier.Cashier == null) - { - throw new Exception("Вы как сюда попали? Суда вход только авторизованным"); - } - - return View(APICashier.GetRequest>($"/api/Account/FindOpenDebiting")); - } - //открытие вьюхи одобрения заявки на зачисление [HttpGet] public IActionResult CloseCrediting() { ViewBag.Creditings = APICashier.GetRequest>("/api/Account/FindOpenCrediting"); + ViewBag.Accounts = APICashier.GetRequest>("/api/Account/GetAllAccounts"); + return View(); } //одобрения заявки на зачисление Post-запросом [HttpPost] - public void CloseCrediting(int creditingId) + public void CloseCrediting(int creditingId, int accountPayeeId) { if (APICashier.Cashier == null) { @@ -284,8 +279,13 @@ namespace BankYouBankruptCashierApp.Controllers throw new Exception("Некорректный номер заявки на зачисление"); } - //получаем необходимые данные для запроса - APICashier.Crediting = APICashier.GetRequest($"/api/Account/FindCrediting?id={creditingId}"); + if (accountPayeeId < 0) + { + throw new Exception("Некорректный id счёта для зацисления средств"); + } + + //получаем необходимые данные для запроса + APICashier.Crediting = APICashier.GetRequest($"/api/Account/FindCrediting?id={creditingId}"); APICashier.Card = APICashier.GetRequest($"/api/Card/FindCard?id={APICashier.Crediting.CardId}"); @@ -294,7 +294,7 @@ namespace BankYouBankruptCashierApp.Controllers CashierId = APICashier.Cashier.Id, CreditingId = creditingId, Sum = APICashier.Crediting.Sum, - AccountPayeeId = APICashier.Card.AccountId + AccountPayeeId = accountPayeeId }); //очистка данных @@ -310,12 +310,14 @@ namespace BankYouBankruptCashierApp.Controllers { ViewBag.Debitings = APICashier.GetRequest>("/api/Account/FindOpenDebiting"); + ViewBag.Accounts = APICashier.GetRequest>("/api/Account/GetAllAccounts"); + return View(); } //одобрения заявки на снятие Post-запросом [HttpPost] - public void CloseDebiting(int debitingId) + public void CloseDebiting(int debitingId, int accountId) { if (APICashier.Cashier == null) { @@ -327,6 +329,11 @@ namespace BankYouBankruptCashierApp.Controllers throw new Exception("Некорректный номер заявки на снятие"); } + if (accountId < 0) + { + throw new Exception("Некорректный номер заявки на снятие"); + } + //получаем необходимые данные для запроса APICashier.Debiting = APICashier.GetRequest($"/api/Account/FindDebiting?id={debitingId}"); @@ -337,10 +344,78 @@ namespace BankYouBankruptCashierApp.Controllers CashierId = APICashier.Cashier.Id, DebitingId = debitingId, Sum = APICashier.Debiting.Sum, - AccountId = APICashier.Card.AccountId + AccountId = accountId }); + APICashier.Debiting = null; + APICashier.Card = null; + Response.Redirect("Debiting"); } + + //получение номера запрашиваемого счёта для снятия + [HttpPost] + public string GetAccountNumber(int id) + { + APICashier.Debiting = APICashier.GetRequest($"/api/Account/FindDebiting?id={id}"); + + APICashier.Crediting = APICashier.GetRequest($"/api/Account/FindDebiting?id={id}"); + + if(APICashier.Debiting == null) + { + APICashier.Card = APICashier.GetRequest($"/api/Card/FindCard?id={APICashier.Crediting.CardId}"); + } + else + { + APICashier.Card = APICashier.GetRequest($"/api/Card/FindCard?id={APICashier.Debiting.CardId}"); + } + + APICashier.Account = APICashier.GetRequest($"/api/Account/GetAccount?accountId={APICashier.Card.AccountId}"); + + string AccountNumber = APICashier.Account.AccountNumber; + + APICashier.Debiting = null; + APICashier.Card = null; + APICashier.Account = null; + + return AccountNumber; + } + + [HttpGet] + public IActionResult MoneyTransfers() + { + ViewBag.Accounts = APICashier.GetRequest>("/api/Account/GetAllAccounts"); + + return View(); + } + + [HttpPost] + public void MoneyTransfers(int accountSenderId, int accountPayeeId, int sumMoneyTransfer) + { + if (APICashier.Cashier == null) + { + throw new Exception("Вы как сюда попали? Суда вход только авторизованным"); + } + + if (accountSenderId < 0) + { + throw new Exception("Некорректный id счёта отправителя"); + } + + if (accountPayeeId < 0) + { + throw new Exception("Некорректный id счёта получателя"); + } + + APICashier.PostRequest("/api/Account/CloseCrediting", new MoneyTransferBindingModel + { + CashierId = APICashier.Cashier.Id, + Sum = sumMoneyTransfer, + AccountPayeeId = accountPayeeId, + AccountSenderId = accountSenderId + }); + + Response.Redirect("Index"); + } } } \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseCrediting.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseCrediting.cshtml index 807f2a5..ab596ae 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseCrediting.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseCrediting.cshtml @@ -9,7 +9,23 @@
Номер запроса на зачисление:
- + +
+
+
+
Запрашиваемый счёт для зачисления:
+
+ +
+
+
+
Номер счёта для зачисления:
+
+
@@ -18,4 +34,23 @@
- \ No newline at end of file + + + + \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseDebiting.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseDebiting.cshtml index 4549d4a..5fbb73c 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseDebiting.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseDebiting.cshtml @@ -9,7 +9,23 @@
Номер запроса на снятие:
- + +
+
+
+
Запрашиваемый счёт для перевода:
+
+ +
+
+
+
Номер счёта для снятия:
+
+
@@ -18,4 +34,23 @@
- \ No newline at end of file + + + + \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Create.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateAccount.cshtml similarity index 87% rename from BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Create.cshtml rename to BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateAccount.cshtml index 64c2f2c..0cec3c9 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Create.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateAccount.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "Create"; + ViewData["Title"] = "Открытие счёта"; }
@@ -9,7 +9,7 @@
Клиент:
- +
diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml index 30e9503..c00de4a 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "CreateReport"; + ViewData["Title"] = "Создание отчёта"; }
diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Enter.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Enter.cshtml index 82f8a43..65705a9 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Enter.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Enter.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "Вход"; + ViewData["Title"] = "Авторизация"; }
diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml index bbaf558..21beb46 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml @@ -18,7 +18,7 @@ return; }

- Открыть счёт + Открыть счёт

diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/MoneyTransfers.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/MoneyTransfers.cshtml new file mode 100644 index 0000000..b4ccb2b --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/MoneyTransfers.cshtml @@ -0,0 +1,37 @@ +@{ + ViewData["Title"] = "Переводы меджу счетами"; +} + +
+

Перевод меджу счетами

+
+ +
+
Номер счёта для снятия:
+
+ +
+
+
+
Номер счёта для начисления:
+
+ +
+
+
+
Сумма перевода:
+
+ +
+
+
+
+
+ +
+
+ diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index 11cceea..a13f342 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -210,7 +210,7 @@ namespace BankYouBankruptClientApp.Controllers } - ViewBag.Cards = APIClient.GetRequest>($"api/Card/GetAllCards").Select(x => new ClientCardViewModel + ViewBag.Cards = APIClient.GetRequest>($"api/Card/GetAllCards").Select(x => new ClientSelectViewModel { Id = x.Id, FullName = x.ClientSurname + " " +x.Number.ToString() diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CardsList.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CardsList.cshtml index d377a36..95ff86a 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CardsList.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CardsList.cshtml @@ -3,7 +3,7 @@ @model List @{ - ViewData["Title"] = "Home Page"; + ViewData["Title"] = "Список карт"; }
diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ClientCardViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ClientSelectViewModel.cs similarity index 90% rename from BankYouBankrupt/BankYouBankruptContracts/ViewModels/ClientCardViewModel.cs rename to BankYouBankrupt/BankYouBankruptContracts/ViewModels/ClientSelectViewModel.cs index 0ef220c..7a5af46 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ClientCardViewModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ClientSelectViewModel.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace BankYouBankruptContracts.ViewModels { - public class ClientCardViewModel + public class ClientSelectViewModel { public int Id { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs index 7b9ea33..c144096 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs @@ -71,6 +71,24 @@ namespace BankYouBankruptRestApi.Controllers } } + //получаем все имеющиеся счета + [HttpGet] + public AccountViewModel? GetAccount(int accountId) + { + try + { + return _accountLogic.ReadElement(new AccountSearchModel + { + Id = accountId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + [HttpPost] public void Register(AccountBindingModel model) { @@ -205,7 +223,7 @@ namespace BankYouBankruptRestApi.Controllers bool flag = true; - //если нет отправителя, т. е. операция на перевод денег из нала в виртуал на карту + //если есть отправитель, т. е. операция на перевод денег со счёта на счёт if (moneyTransfer.AccountSenderId.HasValue) { flag = _accountLogic.ChangeBalance(new AccountSearchModel