Реализован поиск посетителей и удаление посетителей с мероприятия
This commit is contained in:
parent
1fdcf756f9
commit
9b09498ab2
@ -16,6 +16,10 @@ using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using DocumentFormat.OpenXml.Drawing.Diagrams;
|
||||
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace EventVisitorClientApp.Controllers
|
||||
{
|
||||
@ -306,22 +310,32 @@ namespace EventVisitorClientApp.Controllers
|
||||
/// </summary>
|
||||
/// <param></param>
|
||||
/// <returns></returns>
|
||||
///
|
||||
public IActionResult Visitors(int id)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
var allVisitors = APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}");
|
||||
return View(allVisitors);
|
||||
// Ïîëó÷èòå âñåõ ïîñåòèòåëåé
|
||||
var visitors = APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}");
|
||||
return View(visitors);
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult Visitors(int id, string action, string searchTerm, [FromForm] List<int> presentIds)
|
||||
{
|
||||
// Ïîëó÷èòå âñåõ ïîñåòèòåëåé
|
||||
var visitors = APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}");
|
||||
|
||||
if (action == "search" && !string.IsNullOrEmpty(searchTerm))
|
||||
{
|
||||
visitors = visitors.Where(v => v.Name.Contains(searchTerm, StringComparison.OrdinalIgnoreCase) ||
|
||||
v.Email.Contains(searchTerm, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Visitors(int id, [FromForm] List<int> presentIds)
|
||||
if (action == "save")
|
||||
{
|
||||
var allVisitors = APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}");
|
||||
|
||||
foreach (var visitor in allVisitors)
|
||||
foreach (var visitor in visitors)
|
||||
{
|
||||
var status = presentIds.Contains(visitor.Id) ? "Ïðèøåë" : "Çàðåãèñòðèðîâàí";
|
||||
APIClient.PostRequest("api/main/updatevisitor", new VisitorBindingModel
|
||||
@ -330,6 +344,43 @@ namespace EventVisitorClientApp.Controllers
|
||||
Status = status
|
||||
});
|
||||
}
|
||||
|
||||
// Ïîñëå ñîõðàíåíèÿ ïåðåíàïðàâëÿåì îáðàòíî íà ýòîò æå ìåòîä ñ id
|
||||
return RedirectToAction("Visitors", new { id });
|
||||
}
|
||||
|
||||
return View(visitors); // Âåðíóòü ïðåäñòàâëåíèå ñ îòôèëüòðîâàííûì ñïèñêîì
|
||||
}
|
||||
|
||||
public IActionResult DeleteVisitor(int id)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
var existingVisitor = APIClient.GetRequest<VisitorViewModel>($"api/main/GetVisitor?VisitorId={id}");
|
||||
var existingEvent = APIClient.GetRequest<EventViewModel>($"api/main/GetEvent?EventId={existingVisitor.EventId}");
|
||||
int eventId = existingEvent.Id;
|
||||
APIClient.PostRequest($"api/main/DeleteVisitor", new VisitorBindingModel { Id = id });
|
||||
APIClient.PostRequest("api/main/UpdateEvent", new EventBindingModel
|
||||
{
|
||||
Id = existingVisitor.EventId,
|
||||
Name = existingEvent.Name,
|
||||
Description = existingEvent.Description,
|
||||
Type = existingEvent.Type,
|
||||
ContactPhone = existingEvent.ContactPhone,
|
||||
Address = existingEvent.Address,
|
||||
City = existingEvent.City,
|
||||
Status = existingEvent.Status,
|
||||
ContactEmail = existingEvent.ContactEmail,
|
||||
TimeEnd = existingEvent.TimeEnd,
|
||||
TimeStart = existingEvent.TimeStart,
|
||||
Date = existingEvent.Date.ToUniversalTime(),
|
||||
CountVisitors = existingEvent.CountVisitors,
|
||||
FreePlaces = existingEvent.FreePlaces + 1,
|
||||
OrganizerId = APIClient.Client.Id
|
||||
});
|
||||
return Redirect($"~/Home/Visitors/{eventId}");
|
||||
}
|
||||
|
||||
public IActionResult ResultRegistration()
|
||||
|
@ -9,10 +9,20 @@
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Зарегистрированные пользователи</h1>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="text-center mt-4">
|
||||
@{
|
||||
<table class="table table-striped table-bordered mt-4">
|
||||
<form method="post" action="/Home/Visitors">
|
||||
<input type="hidden" name="id" value="@Model.FirstOrDefault()?.EventId" /> <!-- Предполагается, что EventId доступен в модели-->
|
||||
|
||||
<div class="form-group row mt-4">
|
||||
<div class="col-md-10">
|
||||
<input type="text" name="searchTerm" placeholder="Поиск по имени или почте" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="submit" style="background-color:black; color: white; width: 100%; font-size: 20px; border-radius: 5px;" name="action" value="search">Поиск</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive mt-4">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>Имя</th>
|
||||
@ -20,6 +30,7 @@
|
||||
<th>Телефон</th>
|
||||
<th>Дата рождения</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -40,16 +51,19 @@
|
||||
<label class="form-check-label" for="present_@item.Id">Да</label>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-danger btn-sm" asp-action="DeleteVisitor" asp-route-id="@item.Id">Удалить</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
<button type="submit" id="saveButton" class="btn btn-black btn-block">Сохранить</button>
|
||||
</form>
|
||||
<button type="submit" id="saveButton" style="background-color:black; color: white; width: 100%; font-size: 20px; border-radius: 5px;" name="action" value="save">Сохранить</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
@ -58,17 +72,4 @@
|
||||
.table {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-light {
|
||||
background-color: #e9ecef; /* Светло-серый цвет */
|
||||
color: #495057; /* Тёмный текст для контраста */
|
||||
}
|
||||
|
||||
.btn-light:hover {
|
||||
background-color: #d3d3d3; /* Более тёмный светло-серый при наведении */
|
||||
}
|
||||
</style>
|
@ -30,7 +30,6 @@ namespace EventVisitorLogic.Logic
|
||||
|
||||
public bool Delete(VisitorBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_visitorStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
|
@ -155,6 +155,21 @@ namespace EventVisitorRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public VisitorViewModel? GetVisitor(int visitorId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _visitor.ReadElement(new VisitorBindingModel
|
||||
{
|
||||
Id = visitorId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateVisitor(VisitorBindingModel model)
|
||||
{
|
||||
@ -168,6 +183,19 @@ namespace EventVisitorRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteVisitor(VisitorBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_visitor.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteEvent(EventBindingModel model)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user