Отображение списка комнат в плане питания
This commit is contained in:
parent
7a1d52fd99
commit
638978be5b
@ -92,7 +92,7 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
_saveToExcel.CreateReport(new ExcelInfoOrganiser
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список изделий",
|
||||
Title = "Список участников",
|
||||
MemberConferences = GetMemberConference()
|
||||
});
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Primitives" Version="7.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
|
||||
<PackageReference Include="System.Text.Encodings.Web" Version="7.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.2" />
|
||||
|
@ -17,14 +17,15 @@ namespace HotelContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
|
||||
public Dictionary<int, IMemberModel> MealPlanMembers { get; set; } = new();
|
||||
public Dictionary<int, IRoomModel> MealPlanRooms { get; set; }
|
||||
public Dictionary<int, IRoomModel> MealPlanRooms { get; set; } = new();
|
||||
|
||||
public MealPlanViewModel() { }
|
||||
|
||||
[JsonConstructor]
|
||||
public MealPlanViewModel(Dictionary<int, MemberViewModel> MealPlanMembers)
|
||||
public MealPlanViewModel(Dictionary<int, MemberViewModel> MealPlanMembers, Dictionary<int, RoomViewModel> MealPlanRooms)
|
||||
{
|
||||
this.MealPlanMembers = MealPlanMembers.ToDictionary(x => x.Key, x => x.Value as IMemberModel);
|
||||
this.MealPlanRooms = MealPlanRooms.ToDictionary(x => x.Key, x => x.Value as IRoomModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace HotelDataBaseImplement.Models
|
||||
}
|
||||
|
||||
[ForeignKey("MealPlanId")]
|
||||
public virtual List<Room> Rooms { get; set; }
|
||||
public virtual List<Room> Rooms { get; set; } = new();
|
||||
|
||||
[ForeignKey("MealPlanId")]
|
||||
public virtual List<MealPlanMember> Members { get; set; } = new();
|
||||
|
@ -144,13 +144,13 @@ namespace HotelOrganiserApp.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<MealPlanViewModel, string>? GetMealPlan(int mealPlanId)
|
||||
public Tuple<MealPlanViewModel, string, string>? GetMealPlan(int mealPlanId)
|
||||
{
|
||||
if (APIClient.Organiser == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
var result = APIClient.GetRequest<Tuple<MealPlanViewModel, List<Tuple<string, string>>>>($"api/main/getmealplan?mealPlanId={mealPlanId}");
|
||||
var result = APIClient.GetRequest<Tuple<MealPlanViewModel, List<Tuple<string, string>>, List<Tuple<string, string>>>>($"api/main/getmealplan?mealPlanId={mealPlanId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
@ -165,7 +165,17 @@ namespace HotelOrganiserApp.Controllers
|
||||
table += $"<td class=\"u-border-1 u-border-grey-30 u-table-cell\">{citizenship}</td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
return Tuple.Create(result.Item1, table);
|
||||
string tablerooms = "";
|
||||
for (int i = 0; i < result.Item3.Count; i++)
|
||||
{
|
||||
var roomName = result.Item3[i].Item1;
|
||||
var roomFrame = result.Item3[i].Item2;
|
||||
tablerooms += "<tr style=\"height: 44px\">";
|
||||
tablerooms += $"<td class=\"u-border-1 u-border-grey-30 u-table-cell\">{roomName}</td>";
|
||||
tablerooms += $"<td class=\"u-border-1 u-border-grey-30 u-table-cell\">{roomFrame}</td>";
|
||||
tablerooms += "</tr>";
|
||||
}
|
||||
return Tuple.Create(result.Item1, table, tablerooms);
|
||||
}
|
||||
|
||||
public IActionResult AddMemberToMealPlan()
|
||||
|
@ -57,6 +57,28 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="u-table u-table-responsive u-table-1">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Комнаты, связанные с планом питания</label>
|
||||
<table class="u-table-entity">
|
||||
<colgroup>
|
||||
<col width="63%" />
|
||||
<col width="37%" />
|
||||
</colgroup>
|
||||
<thead class="u-custom-color-1 u-table-header u-table-header-1">
|
||||
<tr style="height: 44px">
|
||||
<th class="u-border-1 u-border-black u-table-cell">
|
||||
Номер комнаты
|
||||
</th>
|
||||
<th class="u-border-1 u-border-black u-table-cell">
|
||||
Номер корпуса
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="u-table-body" id="table-elements-rooms">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</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>
|
||||
@ -77,6 +99,7 @@
|
||||
$('#mealPlanName').val(result.item1.mealPlanName);
|
||||
$('#mealPlanPrice').val(result.item1.mealPlanPrice);
|
||||
$('#table-elements').html(result.item2);
|
||||
$('#table-elements-rooms').html(result.item3);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -2,6 +2,7 @@
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataBaseImplement;
|
||||
using HotelDataBaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -370,14 +371,15 @@ namespace HotelRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<MealPlanViewModel, List<Tuple<string, string>>>? GetMealPlan(int mealPlanId)
|
||||
public Tuple<MealPlanViewModel, List<Tuple<string, string>>, List<Tuple<string, string>>>? GetMealPlan(int mealPlanId)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var context = new HotelDataBase();
|
||||
var elem = _mealPlan.ReadElement(new MealPlanSearchModel { Id = mealPlanId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
return Tuple.Create(elem, elem.MealPlanMembers.Select(x => Tuple.Create(x.Value.MemberFIO, x.Value.Citizenship)).ToList());
|
||||
return Tuple.Create(elem, elem.MealPlanMembers.Select(x => Tuple.Create(x.Value.MemberFIO, x.Value.Citizenship)).ToList(), context.Rooms.Where(x => x.MealPlanId == elem.Id).Select(x => Tuple.Create(x.RoomName, x.RoomFrame)).ToList());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user