Настройка компонента select и другой мелочёвки.

This commit is contained in:
Programmist73 2023-05-17 22:27:54 +04:00
parent caac5f3ab2
commit a1742e2ec0
6 changed files with 15 additions and 10 deletions

View File

@ -148,16 +148,21 @@ namespace BankYouBankruptCashierApp.Controllers
//открытие счёта. Получаем и передаём список изделий во вьюху? //открытие счёта. Получаем и передаём список изделий во вьюху?
[HttpGet] [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-запросом //создание заказа Post-запросом
[HttpPost] [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) if (APICashier.Cashier == null)
{ {

View File

@ -9,7 +9,7 @@
<div class="row"> <div class="row">
<div class="col-4">Клиент:</div> <div class="col-4">Клиент:</div>
<div class="col-8"> <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> </div>
<div class="row"> <div class="row">

View File

@ -18,7 +18,7 @@
return; return;
} }
<p> <p>
<a asp-action="Create">Открыть счёт</a> <a asp-action="CreateAccount">Открыть счёт</a>
</p> </p>
<table class="table"> <table class="table">
<thead> <thead>

View File

@ -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, Id = x.Id,
FullName = x.ClientSurname + " " +x.Number.ToString() FullName = x.ClientSurname + " " +x.Number.ToString()

View File

@ -3,7 +3,7 @@
@model List<CardViewModel> @model List<CardViewModel>
@{ @{
ViewData["Title"] = "Home Page"; ViewData["Title"] = "Список карт";
} }
<div class="text-center"> <div class="text-center">

View File

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels namespace BankYouBankruptContracts.ViewModels
{ {
public class ClientCardViewModel public class ClientSelectViewModel
{ {
public int Id { get; set; } public int Id { get; set; }