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 @@ - -