Добавление нескольких участников к плану питания

This commit is contained in:
AnnZhimol 2023-05-19 13:26:52 +04:00
parent 0807bad80f
commit efb32b4b7e
3 changed files with 69 additions and 17 deletions

View File

@ -359,22 +359,25 @@ namespace HotelOrganiserApp.Controllers
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
ViewBag.MealPlans = APIClient.GetRequest<List<MealPlanViewModel>>($"api/main/getmealplanlist?organiserId={APIClient.Organiser.Id}"); return View(Tuple.Create(APIClient.GetRequest<List<MealPlanViewModel>>($"api/main/getmealplanlist?organiserId={APIClient.Organiser.Id}"),
ViewBag.Members = APIClient.GetRequest<List<MemberViewModel>>($"api/main/getmemberlist?organiserId={APIClient.Organiser.Id}"); APIClient.GetRequest<List<MemberViewModel>>($"api/main/getmemberlist?organiserId={APIClient.Organiser.Id}")));
return View(); return View();
} }
[HttpPost] [HttpPost]
public void AddMemberToMealPlan(int mealPlan, int member) public void AddMemberToMealPlan(int mealPlan, int[] member)
{ {
if (APIClient.Organiser == null) if (APIClient.Organiser == null)
{ {
throw new Exception("Необходима авторизация"); throw new Exception("Необходима авторизация");
} }
APIClient.PostRequest("api/main/AddMemberToMealPlan", Tuple.Create( for (int i = 0; i < member.Length; i++)
{
APIClient.PostRequest("api/main/AddMemberToMealPlan", Tuple.Create(
new MealPlanSearchModel() { Id = mealPlan }, new MealPlanSearchModel() { Id = mealPlan },
new MemberViewModel() { Id = member } new MemberViewModel() { Id = member[i] }
)); ));
}
Response.Redirect("ListMealPlans"); Response.Redirect("ListMealPlans");
} }

View File

@ -4,24 +4,73 @@
@{ @{
ViewData["Title"] = "AddMemberToMealPlan"; ViewData["Title"] = "AddMemberToMealPlan";
} }
@model Tuple<List<MealPlanViewModel>, List<MemberViewModel>>
@model Dictionary<int, IMemberModel>
<form method="post"> <form method="post">
<div class="u-form-group u-form-name u-label-top"> <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"> <div class="u-input u-input-rectangle">
<select id="mealPlan" name="mealPlan" class="form-control" asp-items="@(new SelectList(@ViewBag.MealPlans, "Id", "MealPlanName"))"></select> <select id="mealPlan" name="mealPlan" class="form-control">
</div> @foreach (var mealPlan in Model.Item1)
</div> {
<div class="u-form-group u-form-name u-label-top"> <option value="@mealPlan.Id">
<label class="u-label u-text-custom-color-1 u-label-1">Участник: </label> @Html.DisplayFor(modelItem => mealPlan.MealPlanName)
<div class="u-input u-input-rectangle"> </option>
<select id="member" name="member" class="form-control" asp-items="@(new SelectList(@ViewBag.Members, "Id", "MemberFIO"))"></select> }
</select>
</div> </div>
</div> </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="member[]" 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.MemberFIO)
</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.Citizenship)
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top"> <div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div> <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 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> </div>
</form> </form>

View File

@ -82,7 +82,7 @@
asp-area="" asp-controller="Home" asp-action="AddMemberToMealPlan" asp-area="" asp-controller="Home" asp-action="AddMemberToMealPlan"
style="padding: 10 px" style="padding: 10 px"
class="u-active-custom-color-6 u-border-none u-btn u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" class="u-active-custom-color-6 u-border-none u-btn u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1"
>Добавить участника</a> >Добавить участников</a>
<a <a
asp-area="" asp-controller="Home" asp-action="AddRoomToMealPlan" asp-area="" asp-controller="Home" asp-action="AddRoomToMealPlan"
style="padding: 10 px" style="padding: 10 px"