diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs index 9ea6438..61b512e 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs @@ -49,7 +49,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics public List? ReadList(AccountSearchModel? model) { - _logger.LogInformation("ReadList. AccountNumber:{Name}. Id:{Id}", model.AccountNumber, model?.Id); + //_logger.LogInformation("ReadList. AccountNumber:{AccountNumber}. Id:{Id}", model.AccountNumber, model?.Id); //list хранит весь список в случае, если model пришло со значением null на вход метода var list = model == null ? _accountStorage.GetFullList() : _accountStorage.GetFilteredList(model); diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/APICashier.cs b/BankYouBankrupt/BankYouBankruptCashierApp/APICashier.cs index ba338e0..ffc69a1 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/APICashier.cs +++ b/BankYouBankrupt/BankYouBankruptCashierApp/APICashier.cs @@ -25,14 +25,14 @@ namespace BankYouBankruptCashierApp var response = _client.GetAsync(requestUrl); var result = response.Result.Content.ReadAsStringAsync().Result; - //if (response.Result.IsSuccessStatusCode) - //{ - // return JsonConvert.DeserializeObject(result); - //} - //else - //{ - // throw new Exception(result); - //} + if (response.Result.IsSuccessStatusCode) + { + return JsonConvert.DeserializeObject(result); + } + else + { + throw new Exception(result); + } return JsonConvert.DeserializeObject(""); } diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs index aac6730..20486ad 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs @@ -16,17 +16,16 @@ namespace BankYouBankruptCashierApp.Controllers _logger = logger; } - //вытаскивает через API клиента Get-запросом список его собственных заказов - public IActionResult Index() + //вытаскивает через API клиента Get-запросом список его собственных заказов + [HttpGet] + public IActionResult Index() { if (APICashier.Cashier == null) { - //return Redirect("~/Home/Enter"); + return Redirect("~/Home/Enter"); } - //return View(APICashier.GetRequest>($"api/main/getaccounts?cashierId={APICashier.Cashier.Id}")); - - return View(); + return View(APICashier.GetRequest>($"/api/Account/GetAllAccounts")); } //изменемение ланных Get-ом @@ -35,7 +34,7 @@ namespace BankYouBankruptCashierApp.Controllers { if (APICashier.Cashier == null) { - //return Redirect("~/Home/Enter"); + return Redirect("~/Home/Enter"); } return View(APICashier.Cashier); @@ -102,7 +101,7 @@ namespace BankYouBankruptCashierApp.Controllers throw new Exception("Введите логин и пароль"); } - APICashier.Cashier = APICashier.GetRequest($"api/cashier/login?login={login}&password={password}"); + APICashier.Cashier = APICashier.GetRequest($"/api/Cashier/Login?login={login}&password={password}"); if (APICashier.Cashier == null) { @@ -146,13 +145,13 @@ namespace BankYouBankruptCashierApp.Controllers } //открытие счёта. Получаем и передаём список изделий во вьюху? - [HttpGet] + /*[HttpGet] public IActionResult Create() { - //ViewBag.Accountes = APICashier.GetRequest>("api/main/getaccountlist"); + ViewBag.Accountes = APICashier.GetRequest>("/api/Cashier/GetAllAccounts"); return View(); - } + }*/ //создание заказа Post-запросом [HttpPost] @@ -181,7 +180,7 @@ namespace BankYouBankruptCashierApp.Controllers [HttpGet] public IActionResult CreateReport() { - //ViewBag.Accountes = APICashier.GetRequest>("api/main/getaccountlist"); + ViewBag.Accountes = APICashier.GetRequest>("api/main/getaccountlist"); return View(); } @@ -192,7 +191,7 @@ namespace BankYouBankruptCashierApp.Controllers { if (APICashier.Cashier == null) { - //throw new Exception("Вы как сюда попали? Суда вход только авторизованным"); + throw new Exception("Вы как сюда попали? Суда вход только авторизованным"); } if (DateFrom > DateTo) diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml index c762fc1..346b10c 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Index.cshtml @@ -12,12 +12,11 @@
@{ - //if (Model == null) - //{ - //

Сначала авторизируйтесь

- // return; - //} - + if (Model == null) + { +

Сначала авторизируйтесь

+ return; + }

Открыть счёт

@@ -42,6 +41,26 @@ + @foreach (var item in Model) + { + + + @Html.DisplayFor(modelItem => item.AccountNumber) + + + @Html.DisplayFor(modelItem => item.Name) + + + @Html.DisplayFor(modelItem => item.Patronymic) + + + @Html.DisplayFor(modelItem => item.Balance) + + + @Html.DisplayFor(modelItem => item.DateOpen) + + + } } diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/appsettings.json b/BankYouBankrupt/BankYouBankruptCashierApp/appsettings.json index ed01591..ba94e17 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/appsettings.json +++ b/BankYouBankrupt/BankYouBankruptCashierApp/appsettings.json @@ -7,5 +7,5 @@ }, "AllowedHosts": "*", - "IPAddress": "http://localhost:5169/" + "IPAddress": "http://localhost:5179/" } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs index 9b10ae7..f064088 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs @@ -56,7 +56,22 @@ namespace BankYouBankruptRestApi.Controllers } } - [HttpPost] + //получаем все имеющиеся счета + [HttpGet] + public List? GetAllAccounts() + { + try + { + return _accountLogic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + [HttpPost] public void Register(AccountBindingModel model) { try diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CashierController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CashierController.cs index 2c87f23..393df71 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CashierController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CashierController.cs @@ -40,7 +40,25 @@ namespace BankYouBankruptRestApi.Controllers } } - [HttpPost] + [HttpGet] + public CashierViewModel? GetCashier(int id) + { + try + { + //попытка найти запись по переданным логину и паролю + return _cashierLogic.ReadElement(new CashierSearchModel + { + Id = id + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + [HttpPost] public void Register(CashierBindingModel model) { try