From 2adcbcfb1ed42ce95586cf20a416bde3d5bc0388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=BD=D0=B0=20=D0=97=D0=B0=D0=B1=D1=80=D0=BE?= =?UTF-8?q?=D0=B4=D0=B8=D0=BD=D0=B0?= Date: Thu, 2 May 2024 00:55:35 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD?= =?UTF-8?q?=D1=8B=20CRUD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/ConferenceBookingViewModel.cs | 2 - .../ViewModels/MealPlanViewModel.cs | 2 - Hotel/HotelDataBaseImplement/HotelDataBase.cs | 2 +- .../Views/Home/RoomMealPlans.cshtml | 21 +- .../Controllers/HomeController.cs | 184 ++++++++++++++++-- .../Home/ConferenceConferenceBookings.cshtml | 22 +++ .../Views/Home/CreateConference.cshtml | 45 +++++ .../Views/Home/DeleteConference.cshtml | 22 +++ .../Views/Home/ListConferences.cshtml | 67 +++++++ .../Views/Home/UpdateConference.cshtml | 79 ++++++++ .../Views/Home/UpdateMealPlan.cshtml | 25 ++- .../Views/Home/UpdateMember.cshtml | 7 +- .../Views/Shared/_Layout.cshtml | 2 +- .../ConferenceBookingController.cs | 20 ++ .../Controllers/MemberController.cs | 6 +- 15 files changed, 449 insertions(+), 57 deletions(-) create mode 100644 Hotel/HotelOrganiserApp/Views/Home/ConferenceConferenceBookings.cshtml create mode 100644 Hotel/HotelOrganiserApp/Views/Home/CreateConference.cshtml create mode 100644 Hotel/HotelOrganiserApp/Views/Home/DeleteConference.cshtml create mode 100644 Hotel/HotelOrganiserApp/Views/Home/ListConferences.cshtml create mode 100644 Hotel/HotelOrganiserApp/Views/Home/UpdateConference.cshtml diff --git a/Hotel/HotelContracts/ViewModels/ConferenceBookingViewModel.cs b/Hotel/HotelContracts/ViewModels/ConferenceBookingViewModel.cs index 2a50328..6a4a46f 100644 --- a/Hotel/HotelContracts/ViewModels/ConferenceBookingViewModel.cs +++ b/Hotel/HotelContracts/ViewModels/ConferenceBookingViewModel.cs @@ -17,7 +17,5 @@ namespace HotelContracts.ViewModels public string NameHall { get; set; } = string.Empty; public Dictionary ConferenceBookingLunches { get; set; } - - public Dictionary ConferenceConferenceBookings { get; set; } = new(); } } \ No newline at end of file diff --git a/Hotel/HotelContracts/ViewModels/MealPlanViewModel.cs b/Hotel/HotelContracts/ViewModels/MealPlanViewModel.cs index 4997bf6..197a8f4 100644 --- a/Hotel/HotelContracts/ViewModels/MealPlanViewModel.cs +++ b/Hotel/HotelContracts/ViewModels/MealPlanViewModel.cs @@ -17,7 +17,5 @@ namespace HotelContracts.ViewModels public int OrganiserId { get; set; } public Dictionary MealPlanMembers { get; set; } = new(); - - public Dictionary MealPlanRooms { get; set; } = new(); } } \ No newline at end of file diff --git a/Hotel/HotelDataBaseImplement/HotelDataBase.cs b/Hotel/HotelDataBaseImplement/HotelDataBase.cs index d5436cd..bd1a1f2 100644 --- a/Hotel/HotelDataBaseImplement/HotelDataBase.cs +++ b/Hotel/HotelDataBaseImplement/HotelDataBase.cs @@ -10,7 +10,7 @@ namespace HotelDataBaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-M2G96S06\SQLEXPRESS;Initial Catalog=HotelDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-7DB3VEN\SQLEXPRESS;Initial Catalog=HotelDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/Hotel/HotelHeadwaiterApp/Views/Home/RoomMealPlans.cshtml b/Hotel/HotelHeadwaiterApp/Views/Home/RoomMealPlans.cshtml index b96e89c..1e5129d 100644 --- a/Hotel/HotelHeadwaiterApp/Views/Home/RoomMealPlans.cshtml +++ b/Hotel/HotelHeadwaiterApp/Views/Home/RoomMealPlans.cshtml @@ -8,21 +8,16 @@

Связывание номера и плана питания

-
-
Номер:
-
- -
+
+ +
-
-
План питания:
-
- +
+ +
-
-
-
-
+
+
diff --git a/Hotel/HotelOrganiserApp/Controllers/HomeController.cs b/Hotel/HotelOrganiserApp/Controllers/HomeController.cs index 42121cd..4d0c30f 100644 --- a/Hotel/HotelOrganiserApp/Controllers/HomeController.cs +++ b/Hotel/HotelOrganiserApp/Controllers/HomeController.cs @@ -351,32 +351,19 @@ namespace HotelOrganiserApp.Controllers } [HttpGet] - public Tuple? GetMealPlan(int mealPlanId) + public Tuple>? GetMealPlan(int mealPlanId) { if (APIClient.Organiser == null) { throw new Exception("Необходима авторизация"); } - var result = APIClient.GetRequest>>>($"api/mealplan/getmealplan?mealPlanId={mealPlanId}"); + var result = APIClient.GetRequest>>($"api/mealPlan/getmealPlan?mealPlanId={mealPlanId}"); if (result == null) { return default; } - string table = ""; - for (int i = 0; i < result.Item2.Count; i++) - { - var memberSurname = result.Item2[i].Item1; - var memberName = result.Item2[i].Item2; - var memberPatronymic = result.Item2[i].Item3; - var memberPhoneNumber = result.Item2[i].Item4; - table += ""; - table += $"{memberSurname}"; - table += $"{memberName}"; - table += $"{memberPatronymic}"; - table += $"{memberPhoneNumber}"; - table += ""; - } - return Tuple.Create(result.Item1, table); + + return result; } public IActionResult DeleteMealPlan() @@ -403,6 +390,169 @@ namespace HotelOrganiserApp.Controllers Response.Redirect("ListMealPlans"); } + public IActionResult ListConferences() + { + if (APIClient.Organiser == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.GetRequest>($"api/conference/getconferences?organiserId={APIClient.Organiser.Id}")); + } + + public IActionResult CreateConference() + { + if (APIClient.Organiser == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Member = APIClient.GetRequest>($"api/member/getmembers?organiserId={APIClient.Organiser.Id}"); + return View(); + } + + [HttpPost] + public void CreateConference(string conferenceName, DateTime startDate, List memberselect) + { + if (APIClient.Organiser == null) + { + throw new Exception("Необходима авторизация"); + } + if (string.IsNullOrEmpty(conferenceName) || string.IsNullOrEmpty(startDate.ToString())) + { + throw new Exception("Введите название"); + } + if (string.IsNullOrEmpty(startDate.ToString())) + { + throw new Exception("Введите дату"); + } + + Dictionary member = new Dictionary(); + foreach (int members in memberselect) + { + member.Add(members, new MemberSearchModel { Id = members } as IMemberModel); + } + APIClient.PostRequest("api/conference/createconference", new ConferenceBindingModel + { + ConferenceName = conferenceName, + StartDate = startDate, + OrganiserId = APIClient.Organiser.Id, + ConferenceMembers = member + }); + Response.Redirect("ListConferences"); + } + + public IActionResult UpdateConference() + { + if (APIClient.Organiser == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Conferences = APIClient.GetRequest>($"api/conference/getconferences?organiserId={APIClient.Organiser.Id}"); + ViewBag.Member = APIClient.GetRequest>($"api/member/getmembers?organiserId={APIClient.Organiser.Id}"); + return View(); + } + + [HttpPost] + public void UpdateConference(int conference, string conferenceName, DateTime startDate, List memberselect) + { + if (APIClient.Organiser == null) + { + throw new Exception("Необходима авторизация"); + } + if (string.IsNullOrEmpty(conferenceName)) + { + throw new Exception("Название не может быть пустым"); + } + if (string.IsNullOrEmpty(startDate.ToString())) + { + throw new Exception("Дата не может быть пустым"); + } + Dictionary member = new Dictionary(); + foreach (int members in memberselect) + { + member.Add(members, new MemberSearchModel { Id = members } as IMemberModel); + } + APIClient.PostRequest("api/conference/updateconference", new ConferenceBindingModel + { + Id = conference, + ConferenceName = conferenceName, + StartDate = startDate, + OrganiserId = APIClient.Organiser.Id, + ConferenceMembers = member + }); + Response.Redirect("ListConferences"); + } + + [HttpGet] + public Tuple>? GetConference(int conferenceId) + { + if (APIClient.Organiser == null) + { + throw new Exception("Необходима авторизация"); + } + var result = APIClient.GetRequest>>($"api/conference/getconference?conferenceId={conferenceId}"); + if (result == null) + { + return default; + } + + return result; + } + + public IActionResult DeleteConference() + { + if (APIClient.Organiser == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Conferences = APIClient.GetRequest>($"api/conference/getconferences?organiserId={APIClient.Organiser.Id}"); + return View(); + } + + [HttpPost] + public void DeleteConference(int conference) + { + if (APIClient.Organiser == null) + { + throw new Exception("Необходима авторизация"); + } + APIClient.PostRequest("api/conference/deleteconference", new ConferenceBindingModel + { + Id = conference + }); + Response.Redirect("ListConferences"); + } + + public IActionResult ConferenceConferenceBookings() + { + if (APIClient.Organiser == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Conferences = APIClient.GetRequest>($"api/conference/getconferences?organiserId={APIClient.Organiser.Id}"); + ViewBag.ConferenceBookings = APIClient.GetRequest>($"api/conferenceBooking/getconferenceBookings"); + return View(); + } + + [HttpPost] + public void ConferenceConferenceBookings(int conference, int conferenceBooking) + { + if (APIClient.Organiser == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + var roomElem = APIClient.GetRequest($"api/conferenceBooking/getconferenceBookingbyid?conferenceBookingId={conferenceBooking}"); + APIClient.PostRequest("api/conferencebooking/updateconferenceBooking", new ConferenceBookingBindingModel + { + Id = conferenceBooking, + HeadwaiterId = roomElem.HeadwaiterId, + ConferenceId = conference, + BookingDate = roomElem.BookingDate, + NameHall = roomElem.NameHall, + + }); + Response.Redirect("Index"); + } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { diff --git a/Hotel/HotelOrganiserApp/Views/Home/ConferenceConferenceBookings.cshtml b/Hotel/HotelOrganiserApp/Views/Home/ConferenceConferenceBookings.cshtml new file mode 100644 index 0000000..aece875 --- /dev/null +++ b/Hotel/HotelOrganiserApp/Views/Home/ConferenceConferenceBookings.cshtml @@ -0,0 +1,22 @@ +@using HotelContracts.ViewModels; + +@{ + ViewData["Title"] = "ConferenceConferenceBookings"; +} + +
+

Связывание конференции и бронирования по конференции

+
+
+
+ + +
+
+ + +
+
+ +
+
diff --git a/Hotel/HotelOrganiserApp/Views/Home/CreateConference.cshtml b/Hotel/HotelOrganiserApp/Views/Home/CreateConference.cshtml new file mode 100644 index 0000000..b7ce1ad --- /dev/null +++ b/Hotel/HotelOrganiserApp/Views/Home/CreateConference.cshtml @@ -0,0 +1,45 @@ +@using HotelContracts.ViewModels; +@using HotelDataModels.Models; + +@{ + ViewData["Title"] = "CreateConference"; +} + +
+
+

Добавление конференции

+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ +
+
+
+
+ +
+
diff --git a/Hotel/HotelOrganiserApp/Views/Home/DeleteConference.cshtml b/Hotel/HotelOrganiserApp/Views/Home/DeleteConference.cshtml new file mode 100644 index 0000000..aee92f6 --- /dev/null +++ b/Hotel/HotelOrganiserApp/Views/Home/DeleteConference.cshtml @@ -0,0 +1,22 @@ +@{ + ViewData["Title"] = "DeleteConference"; +} + +
+
+

Удаление конференции

+
+
+ + +
+
+
+ +
+
\ No newline at end of file diff --git a/Hotel/HotelOrganiserApp/Views/Home/ListConferences.cshtml b/Hotel/HotelOrganiserApp/Views/Home/ListConferences.cshtml new file mode 100644 index 0000000..cd0ddfe --- /dev/null +++ b/Hotel/HotelOrganiserApp/Views/Home/ListConferences.cshtml @@ -0,0 +1,67 @@ +@using HotelContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "ListConferences"; +} + +
+

Список конференций

+
+ +
+
+
+
+ +
+ + + + + + + + + + @foreach (var item in Model) + { + + + + + + } + +
+ Номер + + Название конференции + + Дата начала конференции +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.ConferenceName) + + @Html.DisplayFor(modelItem => item.StartDate) +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/Hotel/HotelOrganiserApp/Views/Home/UpdateConference.cshtml b/Hotel/HotelOrganiserApp/Views/Home/UpdateConference.cshtml new file mode 100644 index 0000000..74870bb --- /dev/null +++ b/Hotel/HotelOrganiserApp/Views/Home/UpdateConference.cshtml @@ -0,0 +1,79 @@ +@using HotelContracts.ViewModels; +@using HotelDataModels.Models; + +@{ + ViewData["Title"] = "UpdateConference"; +} + +
+
+

Изменение конференции

+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+ +
+
+
+ +
+
+ +@section Scripts +{ + +} \ No newline at end of file diff --git a/Hotel/HotelOrganiserApp/Views/Home/UpdateMealPlan.cshtml b/Hotel/HotelOrganiserApp/Views/Home/UpdateMealPlan.cshtml index e3cbb60..ab88ac1 100644 --- a/Hotel/HotelOrganiserApp/Views/Home/UpdateMealPlan.cshtml +++ b/Hotel/HotelOrganiserApp/Views/Home/UpdateMealPlan.cshtml @@ -10,15 +10,8 @@

Изменение плана питания

- -
- -
+ +
@@ -49,9 +42,8 @@
-
-
-
+
+
@@ -61,21 +53,26 @@ diff --git a/Hotel/HotelOrganiserApp/Views/Home/UpdateMember.cshtml b/Hotel/HotelOrganiserApp/Views/Home/UpdateMember.cshtml index f696e5a..ace2899 100644 --- a/Hotel/HotelOrganiserApp/Views/Home/UpdateMember.cshtml +++ b/Hotel/HotelOrganiserApp/Views/Home/UpdateMember.cshtml @@ -52,15 +52,14 @@ name="memberPhoneNumber" class="form-control" />
-
-
-
+
+
@section Scripts -{ + {