обработка ошибок есть

This commit is contained in:
EkaterinaR 2024-12-01 22:09:38 +04:00
parent 9d302c88ae
commit d2d0f04421
13 changed files with 224 additions and 139 deletions

View File

@ -44,20 +44,27 @@ namespace EventVisitorClientApp.Controllers
return View();
}
[HttpPost]
public void Enter(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Ââåäèòå ëîãèí è ïàðîëü");
}
APIClient.Client = APIClient.GetRequest<OrganizerViewModel>($"api/Organizer/login?login={login}&password={password}");
if (APIClient.Client == null)
{
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
}
Response.Redirect("Index");
}
[HttpGet]
public IActionResult Enter(string login, string password)
{
string returnUrl = HttpContext.Request.Headers["Referer"].ToString();
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
return RedirectToAction("Error", new { errorMessage = "Ââåäèòå ëîãèí è ïàðîëü.", returnUrl });
}
APIClient.Client = APIClient.GetRequest<OrganizerViewModel>($"api/Organizer/login?login={login}&password={password}");
if (APIClient.Client == null)
{
return RedirectToAction("Error", new { errorMessage = "Íåâåðíûé ëîãèí/ïàðîëü.", returnUrl });
}
return RedirectToAction("Index");
}
[HttpGet]
public IActionResult Privacy()
{
if (APIClient.Client == null)
@ -123,34 +130,34 @@ namespace EventVisitorClientApp.Controllers
/// Ìåòîäû äëÿ îðãàíèçàòîðà
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult Register()
{
return View();
}
public IActionResult Logout()
{
APIClient.Client = null;
return Redirect("~/Home/Enter");
}
public static string GenerateRandomString()
[HttpGet]
public IActionResult Register()
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, 6)
.Select(s => s[_random.Next(s.Length)]).ToArray());
return View();
}
[HttpPost]
public void Register(string login, string password, string surname, string name, string lastname, string organizationName, string phone, string code)
{
//var confirmationCode = GenerateRandomString();
//APIClient.PostRequest("api/main/SendToMail", new MailSendInfoBindingModel
//{
// MailAddress = login,
// Subject = "Êîä äëÿ ïîäòâåðæäåíèÿ ðåãèñòðàöèè",
// Text = $"Âàø êîä äëÿ ïîäòâåðæäåíèÿ ðåãèñòðàöèè: {confirmationCode}"
//});
public IActionResult Register(string login, string password, string surname, string name, string lastname, string organizationName, string phone, string code)
{
// Ïîëó÷àåì URL ñòðàíèöû, ñ êîòîðîé ïðèøëè
string returnUrl = HttpContext.Request.Headers["Referer"].ToString();
// Ïðîâåðÿåì, ñóùåñòâóåò ëè ïîëüçîâàòåëü ñ òàêèì ëîãèíîì
var existingUser = APIClient.GetRequest<OrganizerViewModel>($"api/Organizer/GetOrganizer?login={login}");
// Åñëè ïîëüçîâàòåëü ñóùåñòâóåò, ïåðåíàïðàâëÿåì íà ñòðàíèöó îøèáêè
if (existingUser != null)
{
return RedirectToAction("Error", new { errorMessage = "Ïîëüçîâàòåëü ñ òàêèì email óæå ñóùåñòâóåò.", returnUrl });
}
// Åñëè ïîëüçîâàòåëÿ íåò, ïðîäîëæàåì ñ ðåãèñòðàöèåé
APIClient.PostRequest("api/Organizer/Register", new OrganizerBindingModel
{
Name = name,
@ -161,27 +168,11 @@ namespace EventVisitorClientApp.Controllers
Email = login,
Password = password
});
Response.Redirect("Enter");
return;
return RedirectToAction("Enter"); // Ïåðåíàïðàâëåíèå íà ñòðàíèöó âõîäà
}
[HttpPost]
public void CheckCode(string confirmationCode, string login, string password, string surname, string name, string lastname, string organizationName, string phone)
{
// Ïîëó÷àåì ñîõðàí¸ííûé êîä èç ñåññèè
var storedCode = HttpContext.Session.GetString("ConfirmationCode");
if (storedCode == confirmationCode)
{
}
else
{
// Îáðàáîòêà íåïðàâèëüíîãî êîäà, íàïðèìåð, îøèáêà 400
Response.StatusCode = 400;
return;
}
}
/// <summary>
/// Óïðàâëåíèå ìåðîïðèÿòèÿìè
@ -242,15 +233,23 @@ namespace EventVisitorClientApp.Controllers
}
[HttpPost]
public void CreateEvent(string name, string description, string type, string phone, string email, string address, string city, string status, int count, DateTime timestart, DateTime timeend)
public IActionResult CreateEvent(string name, string description, string type, string phone, string email, string address, string city, string status, int count, DateTime timestart, DateTime timeend)
{
if (APIClient.Client == null)
string returnUrl = HttpContext.Request.Headers["Referer"].ToString();
if (timestart < DateTime.UtcNow)
{
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
return RedirectToAction("Error", new { errorMessage = "Äàòà íà÷àëà íå ìîæåò áûòü â ïðîøëîì.", returnUrl });
}
string eventId = Guid.NewGuid().ToString(); // Ãåíåðàöèÿ óíèêàëüíîãî èäåíòèôèêàòîðà äëÿ ìåðîïðèÿòèÿ
string registrationLink = $"https://localhost:7186/registrationonevent?EventId={eventId}"; // Ôîðìèðîâàíèå ññûëêè íà ðåãèñòðàöèþ
if (timestart >= timeend)
{
return RedirectToAction("Error", new { errorMessage = "Äàòà íà÷àëà íå ìîæåò áûòü ïîçæå èëè ðàâíà äàòå îêîí÷àíèÿ.", returnUrl });
}
string eventId = Guid.NewGuid().ToString();
string registrationLink = $"https://localhost:7186/registrationonevent?EventId={eventId}";
APIClient.PostRequest("api/main/createevent", new EventBindingModel
{
@ -264,27 +263,23 @@ namespace EventVisitorClientApp.Controllers
ContactEmail = email,
TimeEnd = timeend.ToUniversalTime(),
TimeStart = timestart.ToUniversalTime(),
Date = DateTime.Now.ToUniversalTime(),
Date = DateTime.UtcNow, // Èñïîëüçóéòå UtcNow äëÿ òåêóùåé äàòû
CountVisitors = count,
FreePlaces = count,
OrganizerId = APIClient.Client.Id,
Link = registrationLink
});
Response.Redirect("MyEvents");
return RedirectToAction("MyEvents");
}
public IActionResult DeleteEvent(int id)
{
// Ïðîâåðêà íà àâòîðèçàöèþ ïîëüçîâàòåëÿ
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
// Âûïîëíåíèå çàïðîñà íà óäàëåíèå ìåðîïðèÿòèÿ
APIClient.PostRequest($"api/main/DeleteEvent", new EventBindingModel { Id = id });
// Ïåðåíàïðàâëåíèå îáðàòíî íà ñòðàíèöó ñ ìåðîïðèÿòèÿìè
return RedirectToAction("MyEvents");
}
@ -300,7 +295,7 @@ namespace EventVisitorClientApp.Controllers
}
[HttpPost]
public void UpdateEvent(int id, string name, string description, string type, string phone, string email, string address, string city, string status, int count, DateTime? timestart, DateTime? timeend)
public IActionResult UpdateEvent(int id, string name, string description, string type, string phone, string email, string address, string city, string status, int count, DateTime? timestart, DateTime? timeend)
{
if (APIClient.Client == null)
{
@ -312,6 +307,19 @@ namespace EventVisitorClientApp.Controllers
int countRegisterPlace = existingEvent.CountVisitors - existingEvent.FreePlaces;
var visitorList = APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}");
string msg = "";
string returnUrl = HttpContext.Request.Headers["Referer"].ToString();
if (timestart < DateTime.UtcNow)
{
return RedirectToAction("Error", new { errorMessage = "Äàòà íà÷àëà íå ìîæåò áûòü â ïðîøëîì.", returnUrl });
}
if (timestart >= timeend)
{
return RedirectToAction("Error", new { errorMessage = "Äàòà íà÷àëà íå ìîæåò áûòü ïîçæå èëè ðàâíà äàòå îêîí÷àíèÿ.", returnUrl });
}
if (existingEvent.TimeStart != timestart && existingEvent.Address != address)
{
msg = $"Âíèìàíèå! Èçìåíèëàñü äàòà íà÷àëà è àäðåññ ìåðîïðèÿòèÿ {existingEvent.Name}. Ìåðîïðèÿòèå íà÷íåòñÿ: {timestart} è ïðîéäåò ïî àäðåññó {address}";
@ -324,12 +332,6 @@ namespace EventVisitorClientApp.Controllers
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 != "")
{
@ -364,7 +366,7 @@ namespace EventVisitorClientApp.Controllers
FreePlaces = count - countRegisterPlace,
OrganizerId = APIClient.Client.Id
});
Response.Redirect("/Home/MyEvents");
return RedirectToAction("MyEvents");
}
/// <summary>
@ -388,13 +390,16 @@ namespace EventVisitorClientApp.Controllers
{
// Ïîëó÷èòå âñåõ ïîñåòèòåëåé
var visitors = APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}");
var visitorsFiltered = new List<VisitorViewModel>();
// Îáðàáîòêà ïîèñêà
if (action == "search" && !string.IsNullOrEmpty(searchTerm))
{
visitors = visitors.Where(v => v.Name.Contains(searchTerm, StringComparison.OrdinalIgnoreCase) ||
visitorsFiltered = visitors.Where(v => v.Name.Contains(searchTerm, StringComparison.OrdinalIgnoreCase) ||
v.Email.Contains(searchTerm, StringComparison.OrdinalIgnoreCase)).ToList();
}
// Îáðàáîòêà ñîõðàíåíèÿ ñòàòóñîâ
if (action == "save")
{
foreach (var visitor in visitors)
@ -407,13 +412,23 @@ namespace EventVisitorClientApp.Controllers
});
}
// Âûñâå÷èâàíèå ñòàòóñà ñîõðàíåíèÿ
TempData["SuccessMessage"] = "Ñòàòóñû ïîñåòèòåëåé óñïåøíî îáíîâëåíû.";
// Ïîñëå ñîõðàíåíèÿ ïåðåíàïðàâëÿåì îáðàòíî íà ýòîò æå ìåòîä ñ id
return RedirectToAction("Visitors", new { id });
}
return View(visitors); // Âåðíóòü ïðåäñòàâëåíèå ñ îòôèëüòðîâàííûì ñïèñêîì
// Åñëè íè÷åãî íå íàéäåíî, âåðíåì âñ¸
if (visitorsFiltered.Any())
{
return View(visitorsFiltered);
}
return View(visitors);
}
public IActionResult DeleteVisitor(int id)
{
if (APIClient.Client == null)
@ -459,11 +474,16 @@ namespace EventVisitorClientApp.Controllers
}
[HttpPost]
public async Task RegistrationOnEventAsync(int id, string name, string phone, string email, DateTime dayBirth)
public async Task<IActionResult> RegistrationOnEventAsync(int id, string name, string phone, string email, DateTime dayBirth)
{
var eventDetails = APIClient.GetRequest<EventViewModel>($"api/main/GetEvent?EventId={id}");
string returnUrl = HttpContext.Request.Headers["Referer"].ToString();
if (eventDetails != null && eventDetails.FreePlaces > 0)
if (dayBirth >= DateTime.Now)
{
return RedirectToAction("Error", new { errorMessage = "Íåâåðíàÿ äàòà ðîæäåíèÿ.", returnUrl });
}
if (eventDetails != null && eventDetails.FreePlaces > 0)
{
int updatedFreePlaces = eventDetails.FreePlaces - 1;
var visitorId = await APIClient.PostRequestAsync("api/main/registrationonevent", new VisitorBindingModel
@ -505,11 +525,11 @@ namespace EventVisitorClientApp.Controllers
Subject = "Ðåãèñòðàöèÿ íà ìåðîïðèÿòèå",
Text = "Âû çàðåãåñòðèðîâàíû íà ìåðîïðèÿòèå " + eventDetails.Name + ", êîòîðîå ïðîéäåò " + eventDetails.TimeStart + ". Ïî àäðåñó: " + eventDetails.Address + " ã. " + eventDetails.City + ".\n" + "×òîáû îòìåíèòü ðåãèñòðàöèþ, íàæìèòå íà ñëåäóþùóþ ññûëêó:" + cancelLink + ".\n" + "Ïî âñåì âîïðîñàì ìîæíî îáðàùàòüñÿ ïî òåëåôîíó: " + eventDetails.ContactPhone + " èëè ïî ïî÷òå: " + eventDetails.ContactEmail + ".\n" + "Áóäåì æäàòü Âàñ íà íàøèõ ìåðîïðèÿòèÿõ!"
});
Response.Redirect("/Home/ResultRegistration");
return Redirect("/Home/ResultRegistration");
}
else
{
Response.Redirect("MyEvents");
return Redirect("MyEvents");
}
}
@ -569,14 +589,15 @@ namespace EventVisitorClientApp.Controllers
}
[HttpPost]
public void ViewEvent(int id, string subject, string message)
public IActionResult ViewEvent(int id, string subject, string message)
{
if (APIClient.Client == null)
{
throw new Exception("Íåîáõîäèìà àâòîðèçàöèÿ");
}
var visitorList = APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}");
if (visitorList != null)
string returnUrl = HttpContext.Request.Headers["Referer"].ToString();
if (visitorList.Count != 0)
{
foreach (var visitor in visitorList)
{
@ -588,6 +609,10 @@ namespace EventVisitorClientApp.Controllers
});
}
}
else
{
return RedirectToAction("Error", new { errorMessage = "Åùå íåò çàðåãèñòðèðîâàííûõ ïîëüçîâàòåëåé", returnUrl });
}
APIClient.PostRequest("api/main/CreateMessage", new SentMessageBindingModel
{
Subject = subject,
@ -596,7 +621,7 @@ namespace EventVisitorClientApp.Controllers
OrganizerId = APIClient.Client.Id,
SentDate = DateTime.Now.ToUniversalTime()
});
Response.Redirect($"/Home/ViewEvent/{id}");
return Redirect($"/Home/ViewEvent/{id}");
}
public IActionResult MessageHistory(int id)
@ -616,7 +641,14 @@ namespace EventVisitorClientApp.Controllers
/// <returns></returns>
public IActionResult GetWordFile()
{
return new PhysicalFileResult("F:\\EventVisitor\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
var filePath = "F:\\EventVisitor\\wordfile.docx";
if (!System.IO.File.Exists(filePath))
{
return NotFound();
}
return new PhysicalFileResult(filePath, "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
}
@ -626,27 +658,31 @@ namespace EventVisitorClientApp.Controllers
}
//[HttpPost]
//public void ReportWord(int[] Ids, int id)
//{
// if (APIClient.Client == null)
// {
// throw new Exception("Âû êàê ñóäà ïîïàëè? Ñóäà âõîä òîëüêî àâòîðèçîâàííûì");
// }
[HttpPost]
public IActionResult ReportWord(int id)
{
if (APIClient.Client == null)
{
throw new Exception("Âû êàê ñóäà ïîïàëè? Ñóäà âõîä òîëüêî àâòîðèçîâàííûì");
}
// List<VisitorViewModel> registeredVisitorsIds = APIClient.GetRequest<List<VisitorViewModel>>($"api/main/GetVisitorList?EventId={id}");
APIClient.PostRequest("api/main/createreporttowordfile", new ReportVisitorsBindingModel
{
EventId = id,
FileName = "F:\\EventVisitor\\wordfile.docx"
});
return RedirectToAction("GetWordFile");
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error(string errorMessage, string returnUrl)
{
ViewBag.ErrorMessage = errorMessage ?? "Ïðîèçîøëà íåèçâåñòíàÿ îøèáêà."; // Äåôîëòíîå ñîîáùåíèå
ViewBag.ReturnUrl = returnUrl; // Ñîõðàíÿåì returnUrl
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
// foreach (var item in Ids)
// {
// res.Add(item);
// }
// APIClient.PostRequest("api/main/createreporttowordfile", new ReportVisitorsBindingModel
// {
// Ids = res,
// FileName = "F:\\EventVisitor\\wordfile.docx"
// });
// Response.Redirect("GetWordFile");
//}
}
}

View File

@ -1,6 +1,6 @@
@{
Layout = null;
ViewData["Title"] = "Успешная регистрация";
ViewData["Title"] = "Отмена регистрации";
}
<head>
@ -16,7 +16,7 @@
<div class="container mt-5">
<div class="row align-items-center justify-content-center">
<div class="col-md-6 text-center">
<h1 class="display-4">Вы успещно отменили регистрацию на мероприятие!</h1>
<h1 class="display-4">Вы успешно отменили регистрацию на мероприятие!</h1>
</div>
</div>
</div>

View File

@ -4,7 +4,7 @@
<div class="row mb-3">
<label for="name" class="col-sm-4 col-form-label">Название мероприятия:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="name" name="name" required>
<input type="text" class="form-control" id="name" name="name" required>
<div class="invalid-feedback">Пожалуйста, введите название мероприятия.</div>
</div>
</div>

View File

@ -68,7 +68,7 @@
{
<a class="btn btn-success btn-sm" asp-action="UpdateEvent" asp-route-id="@item.Id">Редактировать</a>
}
<a class="btn btn-danger btn-sm" asp-action="DeleteEvent" asp-route-id="@item.Id">Удалить</a>
<a class="btn btn-danger btn-sm" asp-action="DeleteEvent" asp-route-id="@item.Id" onclick="return confirm('Вы уверены, что хотите удалить посетителя?');">Удалить</a>
<a class="btn btn btn-secondary btn-sm" asp-action="ViewEvent" asp-route-id="@item.Id">Посмотреть</a>
</td>
</tr>

View File

@ -62,26 +62,22 @@
<div class="mb-4">
<label for="InputEmail" class="form-label" style="font-size: 24px">Введите e-mail</label>
<input type="text" name="email" class="form-control" id="email" required>
<input type="email" name="email" class="form-control" id="email" required>
<div class="invalid-feedback">Пожалуйста, введите e-mail.</div>
</div>
<div class="mb-4">
<label for="InputI" class="form-label" style="font-size: 24px">Введите дату рождения</label>
<label for="dayBirth" class="form-label" style="font-size: 24px">Введите дату рождения</label>
<input type="datetime-local" class="form-control" id="dayBirth" name="dayBirth" required>
<div class="invalid-feedback">Пожалуйста, введите дату рождения.</div>
</div>
<div class="mb-4">
<button type="submit" class="btn btn-dark btn-lg w-100" onclick="submitForm()">Зарегистрироваться</button>
<button type="submit" class="btn btn-dark btn-lg w-100">Зарегистрироваться</button>
</div>
</form>
</div>
</div>
</div>
</div>
</html>
<style>

View File

@ -71,7 +71,10 @@
<button class="btn btn-secondary btn-block mb-4" disabled>Мероприятие уже прошло</button>
}
<a class="btn btn-dark btn-block mb-4" asp-action="Visitors" asp-route-id="@Model.Id">Посетители</a>
<a class="btn btn-dark btn-block mb-4" asp-action="ReportWord" asp-route-id="@Model.Id">Отчет Word о посетителях </a>
<form method="post" asp-action="ReportWord" asp-controller="Home">
<input type="hidden" name="id" value="@Model.Id" />
<button type="submit" class="btn btn-black btn-block" style="margin-bottom: 20px;">Отчет Word о посетителях</button>
</form>
<a class="btn btn-dark btn-block mb-4" asp-action="ReportExcel" asp-route-id="@Model.Id">Отчет Excel о посетителях </a>
</div>
</div>

View File

@ -9,8 +9,11 @@
<div class="text-center">
<h1 class="display-4">Зарегистрированные пользователи</h1>
</div>
<form method="post" asp-action="ReportWord" asp-controller="Home">
<button type="submit" class="btn btn-black btn-block" style="margin-bottom: 20px;">Отчет Word о посетителях</button>
</form>
<form method="post" action="/Home/Visitors">
<input type="hidden" name="id" value="@Model.FirstOrDefault()?.EventId" /> <!-- Предполагается, что EventId доступен в модели-->
<input type="hidden" name="id" value="@Model.FirstOrDefault()?.EventId" />
<div class="form-group row mt-4">
<div class="col-md-10">
@ -52,7 +55,7 @@
</div>
</td>
<td>
<a class="btn btn-danger btn-sm" asp-action="DeleteVisitor" asp-route-id="@item.Id">Удалить</a>
<a class="btn btn-danger btn-sm" asp-action="DeleteVisitor" asp-route-id="@item.Id" onclick="return confirm('Вы уверены, что хотите удалить мероприятие?');">Удалить</a>
</td>
</tr>
}

View File

@ -1,25 +1,39 @@
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
@model EventVisitorClientApp.Models.ErrorViewModel
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div id="errorModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Ошибка</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>@ViewBag.ErrorMessage</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button>
<html>
<head>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div id="errorModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Ошибка</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>@ViewBag.ErrorMessage</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" onclick="window.location.href='@ViewBag.ReturnUrl'">Вернуться</button>
</div>
</div>
</div>
</div>
</div>
and restarting the app.
</p>
<script>
$(document).ready(function () {
var errorMessage = '@ViewBag.ErrorMessage';
if (errorMessage) {
$('#errorModal').modal('show'); // Показываем модальное окно
}
});
</script>
</body>
</html>

View File

@ -1,4 +1,5 @@
using System;
using EventVisitorLogic.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -10,6 +11,6 @@ namespace EventVisitorLogic.BindingModels
{
public string FileName { get; set; } = string.Empty;
public int EventId { get; set; }
public List<int>? Ids { get; set; }
public List<VisitorViewModel> Visitors { get; set; } = new();
}
}

View File

@ -12,6 +12,7 @@ namespace EventVisitorLogic.Logic
{
List<OrganizerViewModel>? ReadList(OrganizerBindingModel? model);
OrganizerViewModel? ReadElement(OrganizerBindingModel model);
OrganizerViewModel? ReadElementEmail(OrganizerBindingModel model);
bool Create(OrganizerBindingModel model);
bool Update(OrganizerBindingModel model);
bool Delete(OrganizerBindingModel model);

View File

@ -78,6 +78,21 @@ namespace EventVisitorLogic.Logic
return null;
}
public OrganizerViewModel? ReadElementEmail(OrganizerBindingModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _organizerStorage.GetElement(model);
if (element != null)
{
return element;
}
return null;
}
public List<OrganizerViewModel>? ReadList(OrganizerBindingModel? model)
{
//var list = model == null ? _organizerStorage.GetFullList() : _organizerStorage.GetFilteredList(model);

View File

@ -75,7 +75,7 @@ namespace EventVisitorLogic.OfficePackage.Implements
_wordDocument = WordprocessingDocument.Create(info.FileName,
WordprocessingDocumentType.Document);
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new DocumentFormat.OpenXml.Wordprocessing.Document();
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
}
protected override void CreateParagraph(WordParagraph paragraph)

View File

@ -35,7 +35,23 @@ namespace EventVisitorRestApi.Controllers
throw;
}
}
[HttpGet]
public OrganizerViewModel? GetOrganizer(string login)
{
try
{
return _logic.ReadElementEmail(new OrganizerBindingModel
{
Email = login
});
}
catch (Exception ex)
{
throw;
}
}
[HttpPost]
public void Register(OrganizerBindingModel model)
{