фулл круд, изменил бд, и ваще блин жесть, Аня гений
This commit is contained in:
parent
78c04095fa
commit
6af99f8e65
@ -382,5 +382,147 @@ namespace HostrelHeadwaiterApp.Controllers
|
||||
Response.Redirect("Enter");
|
||||
return;
|
||||
}
|
||||
|
||||
public IActionResult CreateConferenceBooking()
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateConferenceBooking(string nameHall)
|
||||
{
|
||||
if (string.IsNullOrEmpty(nameHall))
|
||||
{
|
||||
throw new Exception("Введите название");
|
||||
}
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/main/createconferenceBooking", new ConferenceBookingBindingModel
|
||||
{
|
||||
NameHall = nameHall,
|
||||
HeadwaiterId = APIClient.Headwaiter.Id,
|
||||
});
|
||||
Response.Redirect("ListConferenceBookings");
|
||||
}
|
||||
|
||||
public IActionResult DeleteConferenceBooking()
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/main/getconferenceBookinglist?headwaiterId={APIClient.Headwaiter.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteConferenceBooking(int conferenceBooking)
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
APIClient.PostRequest("api/main/deleteconferenceBooking", new ConferenceBookingBindingModel
|
||||
{
|
||||
Id = conferenceBooking
|
||||
});
|
||||
Response.Redirect("ListConferenceBookings");
|
||||
}
|
||||
|
||||
public IActionResult UpdateConferenceBooking()
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/main/getconferenceBookinglist?headwaiterId={APIClient.Headwaiter.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateConferenceBooking(int conferenceBooking, string nameHall)
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
if (string.IsNullOrEmpty(nameHall))
|
||||
{
|
||||
throw new Exception("Название не может быть пустым");
|
||||
}
|
||||
APIClient.PostRequest("api/main/updateconferenceBooking", new ConferenceBookingBindingModel
|
||||
{
|
||||
Id = conferenceBooking,
|
||||
NameHall = nameHall,
|
||||
HeadwaiterId = APIClient.Headwaiter.Id
|
||||
});
|
||||
Response.Redirect("ListConferenceBookings");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<ConferenceBookingViewModel, string>? GetConferenceBooking(int conferenceBookingId)
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
var result = APIClient.GetRequest<Tuple<ConferenceBookingViewModel, List<Tuple<string, string>>>>($"api/main/getconferenceBooking?conferenceBookingId={conferenceBookingId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
string table = "";
|
||||
for (int i = 0; i < result.Item2.Count; i++)
|
||||
{
|
||||
var dinnerName = result.Item2[i].Item1;
|
||||
var dinnerPrice = result.Item2[i].Item2;
|
||||
table += "<tr style=\"height: 44px\">";
|
||||
table += $"<td class=\"u-border-1 u-border-grey-30 u-table-cell\">{dinnerName}</td>";
|
||||
table += $"<td class=\"u-border-1 u-border-grey-30 u-table-cell\">{dinnerPrice}</td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
return Tuple.Create(result.Item1, table);
|
||||
}
|
||||
|
||||
public IActionResult AddDinnerToConferenceBooking()
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/main/getconferenceBookinglist?headwaiterId={APIClient.Headwaiter.Id}");
|
||||
ViewBag.Dinners = APIClient.GetRequest<List<DinnerViewModel>>($"api/main/getdinnerlist?headwaiterId={APIClient.Headwaiter.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void AddDinnerToConferenceBooking(int conferenceBooking, int dinner)
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
APIClient.PostRequest("api/main/AddDinnerToConferenceBooking", Tuple.Create(
|
||||
new ConferenceBookingSearchModel() { Id = conferenceBooking },
|
||||
new DinnerViewModel() { Id = dinner }
|
||||
));
|
||||
Response.Redirect("ListConferenceBookings");
|
||||
}
|
||||
|
||||
public IActionResult ListConferenceBookings()
|
||||
{
|
||||
if (APIClient.Headwaiter == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/main/getconferenceBookinglist?headwaiterId={APIClient.Headwaiter.Id}"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
@using HotelContracts.ViewModels;
|
||||
@using HotelDataModels.Models;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "AddDinnerToConferenceBooking";
|
||||
}
|
||||
|
||||
@model Dictionary<int, IDinnerModel>
|
||||
|
||||
<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>
|
||||
<div class="u-input u-input-rectangle">
|
||||
<select id="conferenceBooking" name="conferenceBooking" class="form-control" asp-items="@(new SelectList(@ViewBag.ConferenceBookings, "Id", "NameHall"))"></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>
|
||||
</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>
|
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateConferenceBooking";
|
||||
}
|
||||
|
||||
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Название зала</label>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Введите название зала"
|
||||
name="nameHall"
|
||||
class="form-control"/>
|
||||
<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>
|
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteConferenceBooking";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
<div class="container d-flex justify-content-center align-items-center0">
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Бронирование: </label>
|
||||
<select id="conferenceBooking" name="conferenceBooking" class="form-control" asp-items="@(new SelectList(@ViewBag.ConferenceBookings, "Id", "NameHall"))"></select>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,80 @@
|
||||
@using HotelContracts.ViewModels
|
||||
|
||||
@model List<ConferenceBookingViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "ListConferenceBookings";
|
||||
}
|
||||
|
||||
|
||||
<section class="u-clearfix u-section-1" id="sec-e38b">
|
||||
<div class="u-clearfix u-sheet u-sheet-1">
|
||||
<div class="u-clearfix u-layout-wrap u-layout-wrap-1">
|
||||
<div class="u-layout">
|
||||
<div class="u-layout-row">
|
||||
<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="table">
|
||||
<thead class="thead-dark">
|
||||
<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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="u-table-body">
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr style="height: 75px">
|
||||
<td
|
||||
class="u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell">
|
||||
@Html.DisplayFor(modelItem => 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.NameHall)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="u-container-style u-layout-cell u-size-12 u-layout-cell-2"
|
||||
>
|
||||
<div class="u-container-layout u-container-layout-2">
|
||||
<a
|
||||
asp-area="" asp-controller="Home" asp-action="CreateConferenceBooking"
|
||||
class="btn btn-outline-dark text-center d-flex justify-content-md-center"
|
||||
>Добавить</a>
|
||||
|
||||
<a
|
||||
asp-area="" asp-controller="Home" asp-action="UpdateConferenceBooking"
|
||||
class="btn btn-outline-dark text-center d-flex justify-content-md-center"
|
||||
>Изменить</a>
|
||||
|
||||
<a
|
||||
asp-area="" asp-controller="Home" asp-action="DeleteConferenceBooking"
|
||||
class="btn btn-outline-dark text-center d-flex justify-content-md-center"
|
||||
>Удалить</a>
|
||||
|
||||
<a
|
||||
asp-area="" asp-controller="Home" asp-action="AddDinnerToConferenceBooking"
|
||||
style="padding: 10 px"
|
||||
class="btn btn-outline-dark text-center d-flex justify-content-md-center"
|
||||
>Добавить обед</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
@ -85,7 +85,7 @@
|
||||
asp-area="" asp-controller="Home" asp-action="AddDinnerToRoom"
|
||||
style="padding: 10 px"
|
||||
class="btn btn-outline-dark text-center d-flex justify-content-md-center"
|
||||
>Добавить комнату</a>
|
||||
>Добавить обед</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -0,0 +1,73 @@
|
||||
@using HotelContracts.ViewModels;
|
||||
@using HotelDataModels.Models;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "UpdateConferenceBooking";
|
||||
}
|
||||
|
||||
|
||||
<form method="post">
|
||||
<div class="container d-flex justify-content-center align-items-center">
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Бронирование: </label>
|
||||
<select id="conferenceBooking" name="conferenceBooking" class="form-control" asp-items="@(new SelectList(@ViewBag.ConferenceBookings, "Id", "NameHall"))"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Название зала</label>
|
||||
<input
|
||||
type="text"
|
||||
id="nameHall"
|
||||
placeholder="Введите название зала"
|
||||
name="nameHall"
|
||||
class="form-control"/>
|
||||
</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="table">
|
||||
<thead class="thead-dark">
|
||||
<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">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var conferenceBooking = $('#conferenceBooking').val();
|
||||
if (conferenceBooking) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetConferenceBooking",
|
||||
data: { conferenceBookingId: conferenceBooking },
|
||||
success: function (result) {
|
||||
$('#nameHall').val(result.item1.nameHall);
|
||||
$('#table-elements').html(result.item2);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#conferenceBooking').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -27,11 +27,9 @@
|
||||
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="ListRooms">Комнаты</a>
|
||||
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="Privacy">Метрдотель</a>
|
||||
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="ListOfMealPlans">Список планов питания</a>
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="ListConferenceBookings">Бронирование</a>
|
||||
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="Report">Отчет по обедам</a>
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="Privacy">Метрдотель</a>
|
||||
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
|
||||
|
@ -3,6 +3,7 @@ using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -22,9 +23,43 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
_logger = logger;
|
||||
_conferenceBookingStorage = conferenceBookingStorage;
|
||||
}
|
||||
|
||||
public bool AddDinnerToConferenceBooking(ConferenceBookingSearchModel model, IDinnerModel dinner)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddDinnerToConferenceBooking. NameHall:{NameHall}.Id:{ Id}", model.NameHall, model.Id);
|
||||
var element = _conferenceBookingStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("AddDinnerToConferenceBooking element not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddDinnerToConferenceBooking find. Id:{Id}", element.Id);
|
||||
|
||||
element.ConferenceBookingDinners[dinner.Id] = dinner;
|
||||
|
||||
_conferenceBookingStorage.Update(new()
|
||||
{
|
||||
Id = element.Id,
|
||||
NameHall = element.NameHall,
|
||||
ConferenceId = element.ConferenceId,
|
||||
HeadwaiterId = element.HeadwaiterId,
|
||||
ConferenceBookingDinners = element.ConferenceBookingDinners
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Create(ConferenceBookingBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
model.ConferenceBookingDinners = new();
|
||||
|
||||
if (_conferenceBookingStorage.Insert(model) == null)
|
||||
{
|
||||
@ -114,6 +149,11 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.NameHall))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия конференции", nameof(model.NameHall));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ConferenceBooking. Id: { Id}", model.Id);
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,9 @@ namespace HotelContracts.BindingModels
|
||||
|
||||
public int? ConferenceId { get; set; }
|
||||
|
||||
public string NameHall { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, IDinnerModel> ConferenceBookingDinners { get; set; }
|
||||
public Dictionary<int, IDinnerModel> ConferenceBookingDinners { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataModels.Models;
|
||||
|
||||
namespace HotelContracts.BusinessLogicsContracts
|
||||
{
|
||||
@ -8,6 +9,7 @@ namespace HotelContracts.BusinessLogicsContracts
|
||||
{
|
||||
List<ConferenceBookingViewModel>? ReadList(ConferenceBookingSearchModel? model);
|
||||
ConferenceBookingViewModel? ReadElement(ConferenceBookingSearchModel model);
|
||||
bool AddDinnerToConferenceBooking(ConferenceBookingSearchModel model, IDinnerModel dinner);
|
||||
bool Create(ConferenceBookingBindingModel model);
|
||||
bool Update(ConferenceBookingBindingModel model);
|
||||
bool Delete(ConferenceBookingBindingModel model);
|
||||
|
@ -6,6 +6,7 @@ namespace HotelContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public int? HeadwaiterId { get; set; }
|
||||
public int? ConferenceId { get; set; }
|
||||
public string NameHall { get; set; } = string.Empty;
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using HotelDataModels.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -13,7 +14,18 @@ namespace HotelContracts.ViewModels
|
||||
|
||||
public int? ConferenceId { get; set; }
|
||||
|
||||
//конференс наме
|
||||
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, IDinnerModel> ConferenceBookingDinners { get; set; }
|
||||
public string NameHall { get; set; } = string.Empty;
|
||||
public Dictionary<int, IDinnerModel> ConferenceBookingDinners { get; set; } = new();
|
||||
|
||||
public ConferenceBookingViewModel() { }
|
||||
|
||||
[JsonConstructor]
|
||||
public ConferenceBookingViewModel(Dictionary<int, DinnerViewModel> ConferenceBookingDinners)
|
||||
{
|
||||
this.ConferenceBookingDinners = ConferenceBookingDinners.ToDictionary(x => x.Key, x => x.Value as IDinnerModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace HotelDataBaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-VG5USAH\SQLEXPRESS;Initial Catalog=HotelDataBaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-V0ON61E\SQLEXPRESS;Initial Catalog=HotelDataBaseFu;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ namespace HotelDataBaseImplement.Implemets
|
||||
using var context = new HotelDataBase();
|
||||
|
||||
var element = context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
@ -34,7 +35,7 @@ namespace HotelDataBaseImplement.Implemets
|
||||
|
||||
public ConferenceBookingViewModel? GetElement(ConferenceBookingSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
if (string.IsNullOrEmpty(model.NameHall) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -48,8 +49,8 @@ namespace HotelDataBaseImplement.Implemets
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.NameHall) && x.NameHall == model.NameHall) || (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ConferenceBookingViewModel> GetFilteredList(ConferenceBookingSearchModel model)
|
||||
@ -60,20 +61,7 @@ namespace HotelDataBaseImplement.Implemets
|
||||
}
|
||||
using var context = new HotelDataBase();
|
||||
|
||||
if (model.DateFrom.HasValue)
|
||||
{
|
||||
return context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.Where(x => x.Conference.StartDate >= model.DateFrom && x.Conference.StartDate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.HeadwaiterId.HasValue)
|
||||
if (model.HeadwaiterId.HasValue) {
|
||||
return context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
@ -82,9 +70,10 @@ namespace HotelDataBaseImplement.Implemets
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.Where(x => x.HeadwaiterId == model.HeadwaiterId)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
||||
}
|
||||
return context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
@ -92,7 +81,8 @@ namespace HotelDataBaseImplement.Implemets
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Where(x => x.NameHall.Contains(model.NameHall))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -140,25 +130,31 @@ namespace HotelDataBaseImplement.Implemets
|
||||
public ConferenceBookingViewModel? Update(ConferenceBookingBindingModel model)
|
||||
{
|
||||
using var context = new HotelDataBase();
|
||||
|
||||
var conferenceBooking = context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.RoomDinners)
|
||||
.ThenInclude(x => x.Room)
|
||||
.Include(x => x.Conference)
|
||||
.Include(x => x.Headwaiter)
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (conferenceBooking == null)
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
return null;
|
||||
var elem = context.ConferenceBookings
|
||||
.Include(x => x.Dinners)
|
||||
.ThenInclude(x => x.Dinner)
|
||||
.ThenInclude(x => x.ConferenceBookingDinner)
|
||||
.ThenInclude(x => x.ConferenceBooking)
|
||||
.ThenInclude(x => x.Conference)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id); if (elem == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
elem.Update(model);
|
||||
context.SaveChanges();
|
||||
if (model.ConferenceBookingDinners != null)
|
||||
elem.UpdateDinners(context, model);
|
||||
transaction.Commit();
|
||||
return elem.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
|
||||
conferenceBooking.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return conferenceBooking.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
570
Hotel/HotelDataBaseImplement/Migrations/20230517182216_plswork.Designer.cs
generated
Normal file
570
Hotel/HotelDataBaseImplement/Migrations/20230517182216_plswork.Designer.cs
generated
Normal file
@ -0,0 +1,570 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HotelDataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HotelDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(HotelDataBase))]
|
||||
[Migration("20230517182216_plswork")]
|
||||
partial class plswork
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ConferenceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("StartDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("Conferences");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("ConferenceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("NameHall")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceId");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.ToTable("ConferenceBookings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConferenceBookingId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DinnerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DinnercId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("NameHall")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceBookingId");
|
||||
|
||||
b.HasIndex("DinnercId");
|
||||
|
||||
b.ToTable("ConferenceBookingDinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConferenceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MemberId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceId");
|
||||
|
||||
b.HasIndex("MemberId");
|
||||
|
||||
b.ToTable("ConferenceMembers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("DinnerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("DinnerPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.ToTable("Dinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("HeadwaiterEmail")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterLogin")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Headwaiters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MealPlanName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("MealPlanPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("MealPlans");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("MealPlanId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MemberId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MealPlanId");
|
||||
|
||||
b.HasIndex("MemberId");
|
||||
|
||||
b.ToTable("MealPlanMembers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Citizenship")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MemberFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("OrganiserEmail")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserLogin")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Organisers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("MealPlanId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("RoomFrame")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("RoomName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("RoomPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.HasIndex("MealPlanId");
|
||||
|
||||
b.ToTable("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DinnerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RoomId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DinnerId");
|
||||
|
||||
b.HasIndex("RoomId");
|
||||
|
||||
b.ToTable("RoomDinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("Conferences")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
|
||||
.WithMany("ConferenceBookings")
|
||||
.HasForeignKey("ConferenceId");
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("ConferenceBookings")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Conference");
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.ConferenceBooking", "ConferenceBooking")
|
||||
.WithMany("Dinners")
|
||||
.HasForeignKey("ConferenceBookingId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
|
||||
.WithMany("ConferenceBookingDinner")
|
||||
.HasForeignKey("DinnercId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ConferenceBooking");
|
||||
|
||||
b.Navigation("Dinner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("ConferenceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
|
||||
.WithMany("ConferenceMembers")
|
||||
.HasForeignKey("MemberId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Conference");
|
||||
|
||||
b.Navigation("Member");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("Dinners")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("MealPlans")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("MealPlanId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
|
||||
.WithMany("MealPlanMember")
|
||||
.HasForeignKey("MemberId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("MealPlan");
|
||||
|
||||
b.Navigation("Member");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("Rooms")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
|
||||
.WithMany("Rooms")
|
||||
.HasForeignKey("MealPlanId");
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
|
||||
b.Navigation("MealPlan");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
|
||||
.WithMany("RoomDinners")
|
||||
.HasForeignKey("DinnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Room", "Room")
|
||||
.WithMany("Dinners")
|
||||
.HasForeignKey("RoomId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dinner");
|
||||
|
||||
b.Navigation("Room");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookings");
|
||||
|
||||
b.Navigation("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.Navigation("Dinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookingDinner");
|
||||
|
||||
b.Navigation("RoomDinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookings");
|
||||
|
||||
b.Navigation("Dinners");
|
||||
|
||||
b.Navigation("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.Navigation("Members");
|
||||
|
||||
b.Navigation("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.Navigation("ConferenceMembers");
|
||||
|
||||
b.Navigation("MealPlanMember");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
|
||||
{
|
||||
b.Navigation("Conferences");
|
||||
|
||||
b.Navigation("MealPlans");
|
||||
|
||||
b.Navigation("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.Navigation("Dinners");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HotelDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class plswork : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Count",
|
||||
table: "ConferenceBookingDinners");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "NameHall",
|
||||
table: "ConferenceBookings",
|
||||
type: "nvarchar(max)",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "NameHall",
|
||||
table: "ConferenceBookingDinners",
|
||||
type: "nvarchar(max)",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "NameHall",
|
||||
table: "ConferenceBookings");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "NameHall",
|
||||
table: "ConferenceBookingDinners");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "Count",
|
||||
table: "ConferenceBookingDinners",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
}
|
||||
}
|
563
Hotel/HotelDataBaseImplement/Migrations/20230517195415_plswork2.Designer.cs
generated
Normal file
563
Hotel/HotelDataBaseImplement/Migrations/20230517195415_plswork2.Designer.cs
generated
Normal file
@ -0,0 +1,563 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HotelDataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HotelDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(HotelDataBase))]
|
||||
[Migration("20230517195415_plswork2")]
|
||||
partial class plswork2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ConferenceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("StartDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("Conferences");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("ConferenceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("NameHall")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceId");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.ToTable("ConferenceBookings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConferenceBookingId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DinnerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceBookingId");
|
||||
|
||||
b.HasIndex("DinnerId");
|
||||
|
||||
b.ToTable("ConferenceBookingDinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConferenceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MemberId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceId");
|
||||
|
||||
b.HasIndex("MemberId");
|
||||
|
||||
b.ToTable("ConferenceMembers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("DinnerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("DinnerPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.ToTable("Dinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("HeadwaiterEmail")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterLogin")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HeadwaiterPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Headwaiters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MealPlanName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("MealPlanPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("MealPlans");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("MealPlanId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MemberId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MealPlanId");
|
||||
|
||||
b.HasIndex("MemberId");
|
||||
|
||||
b.ToTable("MealPlanMembers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Citizenship")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MemberFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("OrganiserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganiserId");
|
||||
|
||||
b.ToTable("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("OrganiserEmail")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserLogin")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrganiserPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Organisers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("MealPlanId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("RoomFrame")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("RoomName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("RoomPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HeadwaiterId");
|
||||
|
||||
b.HasIndex("MealPlanId");
|
||||
|
||||
b.ToTable("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DinnerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RoomId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DinnerId");
|
||||
|
||||
b.HasIndex("RoomId");
|
||||
|
||||
b.ToTable("RoomDinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("Conferences")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
|
||||
.WithMany("ConferenceBookings")
|
||||
.HasForeignKey("ConferenceId");
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("ConferenceBookings")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Conference");
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.ConferenceBooking", "ConferenceBooking")
|
||||
.WithMany("Dinners")
|
||||
.HasForeignKey("ConferenceBookingId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
|
||||
.WithMany("ConferenceBookingDinner")
|
||||
.HasForeignKey("DinnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ConferenceBooking");
|
||||
|
||||
b.Navigation("Dinner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("ConferenceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
|
||||
.WithMany("ConferenceMembers")
|
||||
.HasForeignKey("MemberId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Conference");
|
||||
|
||||
b.Navigation("Member");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("Dinners")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("MealPlans")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("MealPlanId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
|
||||
.WithMany("MealPlanMember")
|
||||
.HasForeignKey("MemberId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("MealPlan");
|
||||
|
||||
b.Navigation("Member");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("OrganiserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organiser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
|
||||
.WithMany("Rooms")
|
||||
.HasForeignKey("HeadwaiterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
|
||||
.WithMany("Rooms")
|
||||
.HasForeignKey("MealPlanId");
|
||||
|
||||
b.Navigation("Headwaiter");
|
||||
|
||||
b.Navigation("MealPlan");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b =>
|
||||
{
|
||||
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
|
||||
.WithMany("RoomDinners")
|
||||
.HasForeignKey("DinnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Room", "Room")
|
||||
.WithMany("Dinners")
|
||||
.HasForeignKey("RoomId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dinner");
|
||||
|
||||
b.Navigation("Room");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookings");
|
||||
|
||||
b.Navigation("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
|
||||
{
|
||||
b.Navigation("Dinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookingDinner");
|
||||
|
||||
b.Navigation("RoomDinners");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
|
||||
{
|
||||
b.Navigation("ConferenceBookings");
|
||||
|
||||
b.Navigation("Dinners");
|
||||
|
||||
b.Navigation("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
|
||||
{
|
||||
b.Navigation("Members");
|
||||
|
||||
b.Navigation("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
|
||||
{
|
||||
b.Navigation("ConferenceMembers");
|
||||
|
||||
b.Navigation("MealPlanMember");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
|
||||
{
|
||||
b.Navigation("Conferences");
|
||||
|
||||
b.Navigation("MealPlans");
|
||||
|
||||
b.Navigation("Members");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.Navigation("Dinners");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HotelDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class plswork2 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_ConferenceBookingDinners_Dinners_DinnercId",
|
||||
table: "ConferenceBookingDinners");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_ConferenceBookingDinners_DinnercId",
|
||||
table: "ConferenceBookingDinners");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DinnercId",
|
||||
table: "ConferenceBookingDinners");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "NameHall",
|
||||
table: "ConferenceBookingDinners");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConferenceBookingDinners_DinnerId",
|
||||
table: "ConferenceBookingDinners",
|
||||
column: "DinnerId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_ConferenceBookingDinners_Dinners_DinnerId",
|
||||
table: "ConferenceBookingDinners",
|
||||
column: "DinnerId",
|
||||
principalTable: "Dinners",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_ConferenceBookingDinners_Dinners_DinnerId",
|
||||
table: "ConferenceBookingDinners");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_ConferenceBookingDinners_DinnerId",
|
||||
table: "ConferenceBookingDinners");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "DinnercId",
|
||||
table: "ConferenceBookingDinners",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "NameHall",
|
||||
table: "ConferenceBookingDinners",
|
||||
type: "nvarchar(max)",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConferenceBookingDinners_DinnercId",
|
||||
table: "ConferenceBookingDinners",
|
||||
column: "DinnercId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_ConferenceBookingDinners_Dinners_DinnercId",
|
||||
table: "ConferenceBookingDinners",
|
||||
column: "DinnercId",
|
||||
principalTable: "Dinners",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
@ -61,6 +61,10 @@ namespace HotelDataBaseImplement.Migrations
|
||||
b.Property<int>("HeadwaiterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("NameHall")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceId");
|
||||
@ -81,20 +85,14 @@ namespace HotelDataBaseImplement.Migrations
|
||||
b.Property<int>("ConferenceBookingId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DinnerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DinnercId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConferenceBookingId");
|
||||
|
||||
b.HasIndex("DinnercId");
|
||||
b.HasIndex("DinnerId");
|
||||
|
||||
b.ToTable("ConferenceBookingDinners");
|
||||
});
|
||||
@ -385,7 +383,7 @@ namespace HotelDataBaseImplement.Migrations
|
||||
|
||||
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
|
||||
.WithMany("ConferenceBookingDinner")
|
||||
.HasForeignKey("DinnercId")
|
||||
.HasForeignKey("DinnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
|
@ -16,6 +16,7 @@ namespace HotelDataBaseImplement.Models
|
||||
public int HeadwaiterId { get; private set; }
|
||||
public int? ConferenceId { get; private set; }
|
||||
public int Id { get; private set; }
|
||||
public string NameHall { get; set; } = string.Empty;
|
||||
public virtual Headwaiter Headwaiter { get; set; }
|
||||
public virtual Conference? Conference { get; set; }
|
||||
|
||||
@ -31,7 +32,10 @@ namespace HotelDataBaseImplement.Models
|
||||
{
|
||||
if (_conferenceBookingDinners == null)
|
||||
{
|
||||
_conferenceBookingDinners = Dinners.ToDictionary(recPC => recPC.DinnerId, recPC => (recPC.Dinner as IDinnerModel));
|
||||
using var context = new HotelDataBase();
|
||||
_conferenceBookingDinners = Dinners
|
||||
.ToDictionary(x => x.DinnerId, x => (context.Dinners
|
||||
.FirstOrDefault(y => y.Id == x.DinnerId)! as IDinnerModel));
|
||||
}
|
||||
return _conferenceBookingDinners;
|
||||
}
|
||||
@ -43,6 +47,7 @@ namespace HotelDataBaseImplement.Models
|
||||
Id = model.Id,
|
||||
ConferenceId = model.ConferenceId,
|
||||
HeadwaiterId = model.HeadwaiterId,
|
||||
NameHall = model.NameHall,
|
||||
Dinners = model.ConferenceBookingDinners.Select(x => new ConferenceBookingDinner
|
||||
{
|
||||
Dinner = context.Dinners.First(y => y.Id == x.Key),
|
||||
@ -54,6 +59,7 @@ namespace HotelDataBaseImplement.Models
|
||||
{
|
||||
ConferenceId = model.ConferenceId;
|
||||
HeadwaiterId = model.HeadwaiterId;
|
||||
NameHall = model.NameHall;
|
||||
}
|
||||
|
||||
public ConferenceBookingViewModel GetViewModel => new()
|
||||
@ -61,17 +67,25 @@ namespace HotelDataBaseImplement.Models
|
||||
Id = Id,
|
||||
ConferenceId = ConferenceId,
|
||||
HeadwaiterId = HeadwaiterId,
|
||||
NameHall = NameHall,
|
||||
ConferenceBookingDinners = ConferenceBookingDinners
|
||||
//новое название = conference?.ConferenceName
|
||||
};
|
||||
|
||||
public void UpdateDinners(HotelDataBase context, ConferenceBookingBindingModel model)
|
||||
{
|
||||
var conferenceBookingDinners = context.ConferenceBookingDinners.Where(rec => rec.ConferenceBookingId == model.Id).ToList();
|
||||
|
||||
if (conferenceBookingDinners != null)
|
||||
if (conferenceBookingDinners != null && conferenceBookingDinners.Count > 0)
|
||||
{
|
||||
context.ConferenceBookingDinners.RemoveRange(conferenceBookingDinners.Where(rec => !model.ConferenceBookingDinners.ContainsKey(rec.DinnerId)));
|
||||
context.SaveChanges();
|
||||
|
||||
foreach (var updateDinner in conferenceBookingDinners)
|
||||
{
|
||||
model.ConferenceBookingDinners.Remove(updateDinner.Id);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
var conferenceBooking = context.ConferenceBookings.First(x => x.Id == Id);
|
||||
|
@ -14,7 +14,6 @@ namespace HotelDataBaseImplement.Models
|
||||
public int DinnerId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual ConferenceBooking ConferenceBooking { get; set; }
|
||||
public virtual Dinner Dinner { get; set; }
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ namespace HotelDataBaseImplement.Models
|
||||
[ForeignKey("DinnerId")]
|
||||
public virtual List<RoomDinner> RoomDinners { get; set; } = new();
|
||||
|
||||
[ForeignKey("DinnercId")]
|
||||
public virtual List<ConferenceBookingDinner> ConferenceBookingDinner { get; set; }
|
||||
[ForeignKey("DinnerId")]
|
||||
public virtual List<ConferenceBookingDinner> ConferenceBookingDinner { get; set; } = new();
|
||||
public static Dinner? Create(DinnerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -520,5 +520,66 @@ namespace HotelRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateConferenceBooking(ConferenceBookingBindingModel model)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
model.ConferenceBookingDinners = null!;
|
||||
_conferenceBooking.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления данных");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<ConferenceBookingViewModel, List<Tuple<string, double>>>? GetConferenceBooking(int conferenceBookingId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _conferenceBooking.ReadElement(new ConferenceBookingSearchModel { Id = conferenceBookingId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
return Tuple.Create(elem, elem.ConferenceBookingDinners.Select(x => Tuple.Create(x.Value.DinnerName, x.Value.DinnerPrice)).ToList());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения по id={Id}", conferenceBookingId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteConferenceBooking(ConferenceBookingBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_conferenceBooking.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления плана питания");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void AddDinnerToConferenceBooking(Tuple<ConferenceBookingSearchModel, DinnerViewModel> model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_conferenceBooking.AddDinnerToConferenceBooking(model.Item1, model.Item2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка добавления участника в план питания.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user