From 4f0275f62126266fb2ea48b9c244a620506036b3 Mon Sep 17 00:00:00 2001 From: EkaterinaR Date: Wed, 6 Nov 2024 11:54:20 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=D0=BE=D1=82=D0=BC=D0=B5=D1=82=D0=BA=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 19 +++++++++++++++- .../Views/Home/Visitors.cshtml | 22 ++++++++++--------- .../EventVisitorLogic/Logic/VisitorLogic.cs | 1 - .../Controllers/MainController.cs | 13 +++++++++++ 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs b/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs index 8047014..7aa474c 100644 --- a/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs +++ b/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs @@ -166,7 +166,24 @@ namespace EventVisitorClientApp.Controllers { return Redirect("~/Home/Enter"); } - return View(APIClient.GetRequest>($"api/main/GetVisitorList?EventId={id}")); + var allVisitors = APIClient.GetRequest>($"api/main/GetVisitorList?EventId={id}"); + return View(allVisitors); + } + + [HttpPost] + public void Visitors(int id, [FromForm] List presentIds) + { + var allVisitors = APIClient.GetRequest>($"api/main/GetVisitorList?EventId={id}"); + + foreach (var visitor in allVisitors) + { + var status = presentIds.Contains(visitor.Id) ? "" : ""; + APIClient.PostRequest("api/main/updatevisitor", new VisitorBindingModel + { + Id = visitor.Id, + Status = status + }); + } } public IActionResult CreateEvent() diff --git a/EventVisitor/EventVisitorClientApp/Views/Home/Visitors.cshtml b/EventVisitor/EventVisitorClientApp/Views/Home/Visitors.cshtml index f287b51..d85ba7e 100644 --- a/EventVisitor/EventVisitorClientApp/Views/Home/Visitors.cshtml +++ b/EventVisitor/EventVisitorClientApp/Views/Home/Visitors.cshtml @@ -9,7 +9,7 @@

Зарегистрированные пользователи

- +
@{ @@ -31,20 +31,22 @@ }
@Html.DisplayFor(modelItem => item.Phone) @Html.DisplayFor(modelItem => item.DayBirth) -
- - -
-
- - -
+
+ + +
} + +
@@ -69,4 +71,4 @@ .btn-light:hover { background-color: #d3d3d3; /* Более тёмный светло-серый при наведении */ } - + \ No newline at end of file diff --git a/EventVisitor/EventVisitorLogic/Logic/VisitorLogic.cs b/EventVisitor/EventVisitorLogic/Logic/VisitorLogic.cs index d5e0c2c..346f9c1 100644 --- a/EventVisitor/EventVisitorLogic/Logic/VisitorLogic.cs +++ b/EventVisitor/EventVisitorLogic/Logic/VisitorLogic.cs @@ -64,7 +64,6 @@ namespace EventVisitorLogic.Logic public bool Update(VisitorBindingModel model) { - CheckModel(model); if (_visitorStorage.Update(model) == null) { return false; diff --git a/EventVisitor/EventVisitorRestApi/Controllers/MainController.cs b/EventVisitor/EventVisitorRestApi/Controllers/MainController.cs index 98e1611..a2f9916 100644 --- a/EventVisitor/EventVisitorRestApi/Controllers/MainController.cs +++ b/EventVisitor/EventVisitorRestApi/Controllers/MainController.cs @@ -120,6 +120,19 @@ namespace EventVisitorRestApi.Controllers } } + [HttpPost] + public void UpdateVisitor(VisitorBindingModel model) + { + try + { + _visitor.Update(model); + } + catch (Exception ex) + { + throw; + } + } + [HttpPost] public void DeleteEvent(EventBindingModel model) {