From 562f48bf3578c4439d0f38cc41a932423712b395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=9A=D1=80?= =?UTF-8?q?=D1=8E=D0=BA=D0=BE=D0=B2?= Date: Tue, 28 May 2024 17:05:44 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D1=8B=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=81=D1=87=D0=B5=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/Cashier/AccountLogic.cs | 10 +- Bank/BankCashierApp/APICashier.cs | 36 +- .../Views/Shared/_Layout.cshtml | 2 - .../20240528115207_init.Designer.cs | 454 ------------------ .../Migrations/20240528115207_init.cs | 324 ------------- 5 files changed, 31 insertions(+), 795 deletions(-) delete mode 100644 Bank/BankDatabaseImplement/Migrations/20240528115207_init.Designer.cs delete mode 100644 Bank/BankDatabaseImplement/Migrations/20240528115207_init.cs diff --git a/Bank/BankBusinessLogic/BusinessLogic/Cashier/AccountLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/Cashier/AccountLogic.cs index e555d4d..c821dc7 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/Cashier/AccountLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/Cashier/AccountLogic.cs @@ -60,7 +60,14 @@ namespace BankBusinessLogic.BusinessLogic.Cashier // Вывод всего списка счетов public List? ReadList(AccountSearchModel? model) { - _logger.LogInformation("ReadList. AccountNumber:{AccountNumber}. Id:{Id}", model.AccountNumber, model?.Id); + if (model != null) + { + _logger.LogInformation("ReadList. AccountNumber:{AccountNumber}. Id:{Id}", model.AccountNumber, model.Id); + } + else + { + _logger.LogInformation("ReadList without filter model"); + } // list хранит весь список в случае, если model пришло со значением null на вход метода var list = model == null ? _accountStorage.GetFullList() : _accountStorage.GetFilteredList(model); @@ -76,6 +83,7 @@ namespace BankBusinessLogic.BusinessLogic.Cashier return list; } + // Метод, отвечающий за изменение баланса счёта public bool ChangeBalance(AccountSearchModel? model, int sum) { diff --git a/Bank/BankCashierApp/APICashier.cs b/Bank/BankCashierApp/APICashier.cs index 42eba21..cc04761 100644 --- a/Bank/BankCashierApp/APICashier.cs +++ b/Bank/BankCashierApp/APICashier.cs @@ -53,24 +53,32 @@ namespace BankCashierApp } } - //Post-запрос - public static void PostRequest(string requestUrl, T model) - { - var json = JsonConvert.SerializeObject(model); - var data = new StringContent(json, Encoding.UTF8, "application/json"); + //Post-запрос + public static async Task PostRequest(string requestUrl, T model) + { + var json = JsonConvert.SerializeObject(model); + var data = new StringContent(json, Encoding.UTF8, "application/json"); - var response = _client.PostAsync(requestUrl, data); + HttpResponseMessage response; + try + { + response = await _client.PostAsync(requestUrl, data).ConfigureAwait(false); + } + catch (Exception ex) + { + throw new Exception("Failed to send POST request", ex); + } - var result = response.Result.Content.ReadAsStringAsync().Result; + if (!response.IsSuccessStatusCode) + { + var result = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new Exception($"Failed to send POST request. Status code: {response.StatusCode}. Response content: {result}"); + } + } - if (!response.Result.IsSuccessStatusCode) - { - throw new Exception(result); - } - } - //Post-запрос для получения данных - public static T? PostRequestReport(string requestUrl, U model) + //Post-запрос для получения данных + public static T? PostRequestReport(string requestUrl, U model) { var json = JsonConvert.SerializeObject(model); var data = new StringContent(json, Encoding.UTF8, "application/json"); diff --git a/Bank/BankCashierApp/Views/Shared/_Layout.cshtml b/Bank/BankCashierApp/Views/Shared/_Layout.cshtml index 416cdb0..6197924 100644 --- a/Bank/BankCashierApp/Views/Shared/_Layout.cshtml +++ b/Bank/BankCashierApp/Views/Shared/_Layout.cshtml @@ -7,8 +7,6 @@ - -