From 01ea8b36ca6f7108e4d66d1613c04633a1e253c8 Mon Sep 17 00:00:00 2001 From: EkaterinaR Date: Fri, 22 Nov 2024 21:17:59 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 80 ++++++++++++++++--- .../Views/Home/MyEvents.cshtml | 43 +++++++++- .../Views/Home/UpdateEvent.cshtml | 3 +- .../Implements/EventStorage.cs | 1 - 4 files changed, 114 insertions(+), 13 deletions(-) diff --git a/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs b/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs index 7b6ddf5..c71b93f 100644 --- a/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs +++ b/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs @@ -20,6 +20,7 @@ using DocumentFormat.OpenXml.Bibliography; using DocumentFormat.OpenXml.Drawing.Diagrams; using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing; using DocumentFormat.OpenXml.Wordprocessing; +using Microsoft.EntityFrameworkCore.Metadata.Conventions; namespace EventVisitorClientApp.Controllers { @@ -186,14 +187,39 @@ namespace EventVisitorClientApp.Controllers /// /// /// - public IActionResult MyEvents() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(APIClient.GetRequest>($"api/main/GetEventList?OrganizerId={APIClient.Client.Id}")); - } + public IActionResult MyEvents(string statusFilter, string typeFilter) + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + + var events = APIClient.GetRequest>($"api/main/GetEventList?OrganizerId={APIClient.Client.Id}"); + + var currentDateTime = DateTime.Now; + + // + if (!string.IsNullOrEmpty(statusFilter)) + { + if (statusFilter == "past") + { + events = events.Where(e => e.TimeStart < currentDateTime).ToList(); + } + else if (statusFilter == "future") + { + events = events.Where(e => e.TimeStart > currentDateTime).ToList(); + } + } + + // + if (!string.IsNullOrEmpty(typeFilter)) + { + events = events.Where(e => e.Type.Equals(typeFilter, StringComparison.OrdinalIgnoreCase)).ToList(); + } + + return View(events); + } + public IActionResult CreateEvent() { if (APIClient.Client == null) @@ -284,10 +310,46 @@ namespace EventVisitorClientApp.Controllers DateTime start = (timestart.HasValue) ? DateTime.SpecifyKind(timestart.Value, DateTimeKind.Utc) : existingEvent.TimeStart.ToUniversalTime(); DateTime end = (timeend.HasValue) ? DateTime.SpecifyKind(timeend.Value, DateTimeKind.Utc) : existingEvent.TimeEnd.ToUniversalTime(); int countRegisterPlace = existingEvent.CountVisitors - existingEvent.FreePlaces; + var visitorList = APIClient.GetRequest>($"api/main/GetVisitorList?EventId={id}"); + string msg = ""; + if (existingEvent.TimeStart != timestart && existingEvent.Address != address) + { + msg = $"! {existingEvent.Name}. : {timestart} {address}"; + + } + else if(existingEvent.TimeStart == timestart && existingEvent.Address != address) + { + msg = $"! {existingEvent.Name}. {address}"; + } + else if(existingEvent.TimeStart != timestart && existingEvent.Address == address) + { + msg = $"! {existingEvent.Name}. : {timestart}"; + APIClient.PostRequest("api/main/SendToMail", new MailSendInfoBindingModel + { + MailAddress = email, + Subject = " ", + Text = msg + }); + } + if (msg != "") + { + if (visitorList.Count != 0) + { + foreach (var visitor in visitorList) + { + APIClient.PostRequest("api/main/SendToMail", new MailSendInfoBindingModel + { + MailAddress = visitor.Email, + Subject = " ", + Text = msg + }); + } + } + } APIClient.PostRequest("api/main/UpdateEvent", new EventBindingModel { Id = id, - Name = name, + Name = existingEvent.Name, Description = description, Type = type, ContactPhone = phone, diff --git a/EventVisitor/EventVisitorClientApp/Views/Home/MyEvents.cshtml b/EventVisitor/EventVisitorClientApp/Views/Home/MyEvents.cshtml index d4a090d..06bb93a 100644 --- a/EventVisitor/EventVisitorClientApp/Views/Home/MyEvents.cshtml +++ b/EventVisitor/EventVisitorClientApp/Views/Home/MyEvents.cshtml @@ -12,10 +12,35 @@
@{ -

Создать мероприятие

+
+
+ + +
+
+ + +
+
+ +
+
@@ -75,4 +100,20 @@ .btn-light:hover { background-color: #d3d3d3; /* Более тёмный светло-серый при наведении */ } + + .row { + display: flex; /* Включаем Flexbox */ + flex-wrap: wrap; /* Разрешаем перенос на следующую строку при необходимости */ + align-items: center; /* Выравнивание по вертикали */ + } + + .col-md-4 { + flex: 1; /* Делаем элементы одинаковой ширины */ + margin-right: 10px; /* Добавляем отступ между элементами */ + } + + .btn-block { + width: 100%; + background-color:black; + } \ No newline at end of file diff --git a/EventVisitor/EventVisitorClientApp/Views/Home/UpdateEvent.cshtml b/EventVisitor/EventVisitorClientApp/Views/Home/UpdateEvent.cshtml index 3f6e9b8..30be31c 100644 --- a/EventVisitor/EventVisitorClientApp/Views/Home/UpdateEvent.cshtml +++ b/EventVisitor/EventVisitorClientApp/Views/Home/UpdateEvent.cshtml @@ -9,8 +9,7 @@
- -
Пожалуйста, введите название мероприятия.
+
diff --git a/EventVisitor/EventVisitorDatabase/Implements/EventStorage.cs b/EventVisitor/EventVisitorDatabase/Implements/EventStorage.cs index 3e58d23..54d2da8 100644 --- a/EventVisitor/EventVisitorDatabase/Implements/EventStorage.cs +++ b/EventVisitor/EventVisitorDatabase/Implements/EventStorage.cs @@ -38,7 +38,6 @@ namespace EventVisitorDatabase.Implements public List GetFilteredList(EventBindingModel model) { using var context = new EventVisitorDbContext(); - return context.Events .Include(x => x.Organizer) .Where(x => x.OrganizerId == model.OrganizerId).Select(x => x.GetViewModel).ToList();