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

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 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() public IActionResult CreateEvent()

View File

@ -9,7 +9,7 @@
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Зарегистрированные пользователи</h1> <h1 class="display-4">Зарегистрированные пользователи</h1>
</div> </div>
<form method="post">
<div class="text-center mt-4"> <div class="text-center mt-4">
@{ @{
<table class="table table-striped table-bordered mt-4"> <table class="table table-striped table-bordered mt-4">
@ -31,20 +31,22 @@
<td>@Html.DisplayFor(modelItem => item.Phone)</td> <td>@Html.DisplayFor(modelItem => item.Phone)</td>
<td>@Html.DisplayFor(modelItem => item.DayBirth)</td> <td>@Html.DisplayFor(modelItem => item.DayBirth)</td>
<td> <td>
<div class="form-check form-check-inline"> <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"
<label class="form-check-label" for="present_@item.Id">Да</label> id="present_@item.Id"
</div> name="presentIds"
<div class="form-check form-check-inline"> value="@item.Id"
<input class="form-check-input" type="checkbox" id="not_present_@item.Id" name="not_present_@item.Id" value="true"> @(item.Status == "Пришел" ? "checked" : "")>
<label class="form-check-label" for="not_present_@item.Id">Нет</label> <label class="form-check-label" for="present_@item.Id">Да</label>
</div> </div>
</td> </td>
</tr> </tr>
} }
</tbody> </tbody>
</table> </table>
} }
<button type="submit" id="saveButton" class="btn btn-black btn-block">Сохранить</button>
</form>
</div> </div>
</div> </div>

View File

@ -64,7 +64,6 @@ namespace EventVisitorLogic.Logic
public bool Update(VisitorBindingModel model) public bool Update(VisitorBindingModel model)
{ {
CheckModel(model);
if (_visitorStorage.Update(model) == null) if (_visitorStorage.Update(model) == null)
{ {
return false; 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] [HttpPost]
public void DeleteEvent(EventBindingModel model) public void DeleteEvent(EventBindingModel model)
{ {