Часть 2 готова

This commit is contained in:
Кашин Максим 2023-05-19 21:06:22 +04:00
parent 389a872716
commit e0dd8ad335
2 changed files with 74 additions and 24 deletions

View File

@ -266,22 +266,24 @@ namespace HostrelHeadwaiterApp.Controllers
{
return Redirect("~/Home/Enter");
}
ViewBag.Rooms = APIClient.GetRequest<List<RoomViewModel>>($"api/main/getroomlist?headwaiterId={APIClient.Headwaiter.Id}");
ViewBag.Dinners = APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?headwaiterId={APIClient.Headwaiter.Id}");
return View();
return View(Tuple.Create(APIClient.GetRequest<List<RoomViewModel>>($"api/main/getroomlist?headwaiterId={APIClient.Headwaiter.Id}"),
APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?headwaiterId={APIClient.Headwaiter.Id}")));
}
[HttpPost]
public void AddDinnerToRoom(int room, int dinner)
public void AddDinnerToRoom(int room, int[] dinner)
{
if (APIClient.Headwaiter == null)
{
throw new Exception("Необходима авторизация");
}
APIClient.PostRequest("api/main/AddDinnerToRoom", Tuple.Create(
new RoomSearchModel() { Id = room },
new DinnerViewModel() { Id = dinner }
));
for (int i = 0; i < dinner.Length; i++)
{
APIClient.PostRequest("api/main/AddDinnerToRoom", Tuple.Create(
new RoomSearchModel() { Id = room },
new DinnerViewModel() { Id = dinner[i] }
));
}
Response.Redirect("ListRooms");
}
@ -504,7 +506,7 @@ namespace HostrelHeadwaiterApp.Controllers
return Redirect("~/Home/Enter");
}
return View(Tuple.Create(APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/main/getconferencebookinglist?headwaiterId={APIClient.Headwaiter.Id}"),
APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?headwaiterId={APIClient.Headwaiter.Id}"))); return View();
APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?headwaiterId={APIClient.Headwaiter.Id}")));
}
[HttpPost]

View File

@ -1,29 +1,77 @@
@using HotelContracts.ViewModels;
@using HotelContracts.ViewModels;
@using HotelDataModels.Models;
@{
ViewData["Title"] = "AddDinnerToRoom";
}
@model Dictionary<int, IDinnerModel>
@model Tuple<List<RoomViewModel>, List<DinnerViewModel>>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Комнаты: </label>
<label class="u-label u-text-custom-color-1 u-label-1">Конференции: </label>
<div class="u-input u-input-rectangle">
<select id="room" name="room" class="form-control" asp-items="@(new SelectList(@ViewBag.Rooms, "Id", "RoomName"))"></select>
<select id="room" name="room" class="form-control">
@foreach (var room in Model.Item1)
{
<option value="@room.Id">
@Html.DisplayFor(modelItem => room.RoomName)
</option>
}
</select>
</div>
</div>
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Обеды: </label>
<div class="u-input u-input-rectangle">
<select id="dinner" name="dinner" class="form-control" asp-items="@(new SelectList(@ViewBag.Dinners, "Id", "DinnerName"))"></select>
</div>
<label class="u-label u-text-custom-color-1 u-label-1">Участники: </label>
<div class="u-container-style u-layout-cell u-size-48 u-layout-cell-1">
<div class="u-container-layout u-container-layout-1">
<div class="u-table u-table-responsive u-table-1">
<table class="u-table-entity">
<colgroup>
<col width="9.8%" />
<col width="62.9%" />
<col width="27.3%" />
</colgroup>
<thead
class="u-custom-color-1 u-table-header u-table-header-1">
<tr style="height: 31px">
<th class="u-border-1 u-border-grey-50 u-table-cell">
</th>
<th class="u-border-1 u-border-grey-50 u-table-cell">
ФИО участника
</th>
<th class="u-border-1 u-border-grey-50 u-table-cell">
Гражданство
</th>
</tr>
</thead>
<tbody class="u-table-body">
@foreach (var item in Model.Item2)
{
<tr style="height: 75px">
<td
class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell">
<input type="checkbox" class="form-check-input" name="dinner[]" value="@item.Id" id="@item.Id">
</td>
<td
class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell"
>
@Html.DisplayFor(modelItem => item.DinnerName)
</td>
<td
class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell"
>
@Html.DisplayFor(modelItem => item.DinnerPrice)
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Добавить участников" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
<br>
<div class="u-container-layout u-container-layout-2">
<input type="submit" value="Сохранить" class="btn btn-outline-dark text-center d-flex justify-content-md-center" />
</div>
</form>