From 0e96f959d2e7b37d757f3f04140253f9838874e8 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Wed, 17 May 2023 18:26:43 +0400 Subject: [PATCH] CloseCrediting.cshtml --- BankYouBankrupt/BankYouBankrupt.sln | 2 +- .../BankYouBankruptCashierApp/APICashier.cs | 12 +++++- .../Controllers/HomeController.cs | 39 +++++++++++++++++++ .../Views/Home/CloseCrediting.cshtml | 21 ++++++++++ .../Views/Home/CloseDebiting.cshtml | 5 +++ .../Views/Home/Crediting.cshtml | 2 +- .../Controllers/AccountController.cs | 17 ++++++++ .../Controllers/CardController.cs | 19 ++++++++- 8 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseCrediting.cshtml create mode 100644 BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseDebiting.cshtml diff --git a/BankYouBankrupt/BankYouBankrupt.sln b/BankYouBankrupt/BankYouBankrupt.sln index a4286b0..2d6f84a 100644 --- a/BankYouBankrupt/BankYouBankrupt.sln +++ b/BankYouBankrupt/BankYouBankrupt.sln @@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankYouBankruptRestAPI", "B EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankYouBankruptCashierApp", "BankYouBankruptCashierApp\BankYouBankruptCashierApp.csproj", "{3530E2D9-CC6C-4F88-B9AA-90F5E6BBDE01}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankYouBankruptClientApp", "BankYouBankruptClientApp\BankYouBankruptClientApp.csproj", "{8AD664D9-240B-41CD-9AB6-B56C64AC4291}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankYouBankruptClientApp", "BankYouBankruptClientApp\BankYouBankruptClientApp.csproj", "{8AD664D9-240B-41CD-9AB6-B56C64AC4291}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/APICashier.cs b/BankYouBankrupt/BankYouBankruptCashierApp/APICashier.cs index 7fb417b..27f4f64 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/APICashier.cs +++ b/BankYouBankrupt/BankYouBankruptCashierApp/APICashier.cs @@ -9,10 +9,18 @@ namespace BankYouBankruptCashierApp { private static readonly HttpClient _client = new(); - //поле, хранящее кассира, которого необходимо авторизовать + //Вью-модели, необходимые для дальнейшего генерирования запросов к апишке public static CashierViewModel? Cashier { get; set; } = null; - public static void Connect(IConfiguration configuration) + public static CreditingViewModel? Crediting { get; set; } = null; + + public static DebitingViewModel? Debiting { get; set; } = null; + + public static AccountViewModel? Account { get; set; } = null; + + public static CardViewModel? Card { get; set; } = null; + + public static void Connect(IConfiguration configuration) { _client.BaseAddress = new Uri(configuration["IPAddress"]); _client.DefaultRequestHeaders.Accept.Clear(); diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs index 96dd755..3b413b3 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs @@ -258,5 +258,44 @@ namespace BankYouBankruptCashierApp.Controllers return View(APICashier.GetRequest>($"/api/Account/FindOpenDebiting")); } + + //открытие формы отчёта. Получаем и передаём список изделий во вьюху? + [HttpGet] + public IActionResult CloseCrediting() + { + ViewBag.Creditings = APICashier.GetRequest>("/api/Account/FindOpenCrediting"); + + return View(); + } + + //создание отчёта Post-запросом + [HttpPost] + public void CloseCrediting(int creditingId) + { + if (APICashier.Cashier == null) + { + throw new Exception("Вы как сюда попали? Суда вход только авторизованным"); + } + + if(creditingId < 0) + { + throw new Exception("Некорректный номер заявки на зачисление"); + } + + //получаем необходимые данные для запроса + APICashier.Crediting = APICashier.GetRequest($"/api/Account/FindCrediting?id={creditingId}"); + + APICashier.Card = APICashier.GetRequest($"/api/Card/FindCard?id={APICashier.Crediting.CardId}"); + + APICashier.PostRequest("/api/Account/CloseCrediting", new MoneyTransferBindingModel + { + CashierId = APICashier.Cashier.Id, + CreditingId = creditingId, + Sum = APICashier.Crediting.Sum, + AccountPayeeId = APICashier.Card.AccountId + }); + + Response.Redirect("Crediting"); + } } } \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseCrediting.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseCrediting.cshtml new file mode 100644 index 0000000..42ac2bf --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseCrediting.cshtml @@ -0,0 +1,21 @@ +@{ + ViewData["Title"] = "Одобрение зачислений"; +} + +
+

Зачисление

+
+
+
+
Номер запроса на зачисление:
+
+ +
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseDebiting.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseDebiting.cshtml new file mode 100644 index 0000000..e1dd794 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CloseDebiting.cshtml @@ -0,0 +1,5 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +} diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Crediting.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Crediting.cshtml index b66e4ef..2594260 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Crediting.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Crediting.cshtml @@ -18,7 +18,7 @@ return; }

- Одобрение заявки + Одобрение заявки

diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs index f064088..a19c061 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs @@ -222,5 +222,22 @@ namespace BankYouBankruptRestApi.Controllers throw; } } + + [HttpGet] + public CreditingViewModel FindCrediting(int id) + { + try + { + return _creditingLogic.ReadElement(new CreditingSearchModel + { + Id = id + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } } } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs index 54208e8..92e6dac 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs @@ -82,5 +82,22 @@ namespace BankYouBankruptRestApi.Controllers Response.StatusCode = (int)HttpStatusCode.NotAcceptable; } } - } + + [HttpGet] + public CardViewModel FindCard(int id) + { + try + { + return _cardLogic.ReadElement(new CardSearchModel + { + Id = id + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + } }