работает отметка посещения

This commit is contained in:
EkaterinaR 2024-11-06 11:54:20 +04:00
parent 60740d3ca9
commit 4f0275f621
4 changed files with 43 additions and 12 deletions

View File

@ -166,7 +166,24 @@ namespace EventVisitorClientApp.Controllers
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}"));
var allVisitors = APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}");
return View(allVisitors);
}
[HttpPost]
public void Visitors(int id, [FromForm] List<int> presentIds)
{
var allVisitors = APIClient.GetRequest<List<VisitorViewModel>>($"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()

View File

@ -9,7 +9,7 @@
<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">
@ -32,19 +32,21 @@
<td>@Html.DisplayFor(modelItem => item.DayBirth)</td>
<td>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="present_@item.Id" name="present_@item.Id" value="true">
<input class="form-check-input visitor-checkbox" type="checkbox"
id="present_@item.Id"
name="presentIds"
value="@item.Id"
@(item.Status == "Пришел" ? "checked" : "")>
<label class="form-check-label" for="present_@item.Id">Да</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="not_present_@item.Id" name="not_present_@item.Id" value="true">
<label class="form-check-label" for="not_present_@item.Id">Нет</label>
</div>
</td>
</tr>
}
</tbody>
</table>
}
<button type="submit" id="saveButton" class="btn btn-black btn-block">Сохранить</button>
</form>
</div>
</div>

View File

@ -64,7 +64,6 @@ namespace EventVisitorLogic.Logic
public bool Update(VisitorBindingModel model)
{
CheckModel(model);
if (_visitorStorage.Update(model) == null)
{
return false;

View File

@ -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)
{