From a1742e2ec08750b58733db9e4ae1e2359f5c9911 Mon Sep 17 00:00:00 2001 From: Programmist73 <egor.eliseev.1986@mail.ru> Date: Wed, 17 May 2023 22:27:54 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=20select=20=D0=B8=20=D0=B4=D1=80=D1=83=D0=B3=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=BC=D0=B5=D0=BB=D0=BE=D1=87=D1=91=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 15 ++++++++++----- .../Home/{Create.cshtml => CreateAccount.cshtml} | 2 +- .../Views/Home/Index.cshtml | 2 +- .../Controllers/HomeController.cs | 2 +- .../Views/Home/CardsList.cshtml | 2 +- ...tCardViewModel.cs => ClientSelectViewModel.cs} | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) rename BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/{Create.cshtml => CreateAccount.cshtml} (92%) rename BankYouBankrupt/BankYouBankruptContracts/ViewModels/{ClientCardViewModel.cs => ClientSelectViewModel.cs} (90%) diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs index 391f795..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<List<ClientViewModel>>("/api/Client/GetAllClients"); + //запрашиваем список в формате вспомогательной вьюшки из-за работы select в asp net + ViewBag.Clients = APICashier.GetRequest<List<ClientViewModel>>($"/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) { diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Create.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateAccount.cshtml similarity index 92% rename from BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Create.cshtml rename to BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateAccount.cshtml index 2486046..0cec3c9 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/Create.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateAccount.cshtml @@ -9,7 +9,7 @@ <div class="row"> <div class="col-4">Клиент:</div> <div class="col-8"> - <select id="client" name="clientId" class="form-control" asp-items="@(new SelectList( @ViewBag.Clients, "Id", "Surname"))"></select> + <select id="client" name="clientId" class="form-control" asp-items="@(new SelectList( @ViewBag.Clients, "Id", "FullName"))"></select> </div> </div> <div class="row"> 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; } <p> - <a asp-action="Create">Открыть счёт</a> + <a asp-action="CreateAccount">Открыть счёт</a> </p> <table class="table"> <thead> diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index f4fae54..0393708 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -211,7 +211,7 @@ namespace BankYouBankruptClientApp.Controllers } - ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetAllCards").Select(x => new ClientCardViewModel + ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"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<CardViewModel> @{ - ViewData["Title"] = "Home Page"; + ViewData["Title"] = "Список карт"; } <div class="text-center"> 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; }