diff --git a/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs b/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs index 405d5f2..75e9423 100644 --- a/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs +++ b/EventVisitor/EventVisitorClientApp/Controllers/HomeController.cs @@ -185,6 +185,35 @@ namespace EventVisitorClientApp.Controllers return View(eventDetails); } + + public IActionResult RegistrationOnEvent(int id) + { + var eventDetails = APIClient.GetRequest($"api/main/GetEvent?EventId={id}"); + + return View(eventDetails); + } + + [HttpPost] + public void RegistrationOnEvent(int id, string name, string phone, string email, DateTime dayBirth) + { + APIClient.PostRequest("api/main/registrationonevent", new VisitorBindingModel + { + Name = name, + Phone = phone, + Email = email, + DayBirth = dayBirth.ToUniversalTime(), + EventId = id, + Status = "" + }); + Response.Redirect("ResultRegistration"); + } + + [HttpGet] + public IActionResult ResultRegistration() + { + return View(); + } + [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) { @@ -192,6 +221,10 @@ namespace EventVisitorClientApp.Controllers { throw new Exception(" ? "); } + + string eventId = Guid.NewGuid().ToString(); // + string registrationLink = $"https://localhost:7186/registrationonevent?EventId={eventId}"; // + APIClient.PostRequest("api/main/createevent", new EventBindingModel { Name = name, @@ -208,7 +241,7 @@ namespace EventVisitorClientApp.Controllers CountVisitors = count, FreePlaces = count, OrganizerId = APIClient.Client.Id, - Link = "" + Link = registrationLink }); Response.Redirect("MyEvents"); } @@ -239,17 +272,6 @@ namespace EventVisitorClientApp.Controllers return View(eventDetails); } - //public IActionResult GenerateLink(EventViewModel model, int id) - //{ - // if (APIClient.Client == null) - // { - // return Redirect("~/Home/Enter"); - // } - // var eventDetails = APIClient.GetRequest($"api/main/GetEvent?EventId={id}"); - // var registrationLink = Url.Action("Register", "Events", eventid = id, Request.Scheme); - - // return View(eventDetails); - //} [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) diff --git a/EventVisitor/EventVisitorClientApp/Views/Home/CreateEvent.cshtml b/EventVisitor/EventVisitorClientApp/Views/Home/CreateEvent.cshtml index fc7c7b3..b9aac81 100644 --- a/EventVisitor/EventVisitorClientApp/Views/Home/CreateEvent.cshtml +++ b/EventVisitor/EventVisitorClientApp/Views/Home/CreateEvent.cshtml @@ -96,3 +96,4 @@ + \ No newline at end of file diff --git a/EventVisitor/EventVisitorClientApp/Views/Home/RegistrationOnEvent.cshtml b/EventVisitor/EventVisitorClientApp/Views/Home/RegistrationOnEvent.cshtml index e99e97f..0f46fb4 100644 --- a/EventVisitor/EventVisitorClientApp/Views/Home/RegistrationOnEvent.cshtml +++ b/EventVisitor/EventVisitorClientApp/Views/Home/RegistrationOnEvent.cshtml @@ -1,40 +1,75 @@ -@{ +@using EventVisitorLogic.ViewModels +@model EventViewModel + +@{ ViewData["Title"] = "RegistrationOnEvent"; } -
-

Регистрация на мероприятие

- -
-
- - -
Пожалуйста, введите имя.
+
+
+
+
+
+

@Html.DisplayFor(model => model.Name)

+
+
+

Описание:

+

@Html.DisplayFor(model => model.Description)

+

Дата начала:

+

@Html.DisplayFor(model => model.TimeStart)

+

Дата окончания:

+

@Html.DisplayFor(model => model.TimeEnd)

+

Статус:

+

@Html.DisplayFor(model => model.Status)

+

Город:

+

@Html.DisplayFor(model => model.City)

+

Адрес:

+

@Html.DisplayFor(model => model.Address)

+

Всего мест:

+

@Html.DisplayFor(model => model.CountVisitors)

+

Свободных мест:

+

@Html.DisplayFor(model => model.FreePlaces)

+
+
+
+
+

Регистрация на мероприятие

-
- - -
Пожалуйста, введите номер телефона.
-
+ +
+ + +
Пожалуйста, введите имя.
+
-
- - -
Пожалуйста, введите e-mail.
-
+
+ + +
Пожалуйста, введите номер телефона.
+
-
- - -
Пожалуйста, введите дату рождения.
-
+
+ + +
Пожалуйста, введите e-mail.
+
-
- +
+ + +
Пожалуйста, введите дату рождения.
+
+ +
+ +
+ +
- +
+ - - - - - - - - diff --git a/EventVisitor/EventVisitorClientApp/Views/Home/ResultRegistration.cshtml b/EventVisitor/EventVisitorClientApp/Views/Home/ResultRegistration.cshtml new file mode 100644 index 0000000..41ac676 --- /dev/null +++ b/EventVisitor/EventVisitorClientApp/Views/Home/ResultRegistration.cshtml @@ -0,0 +1,39 @@ +@{ + ViewData["Title"] = "Успешная регистрация"; +} + +
+
+
+
+
+

Успешная регистрация

+
+
+

Вы успешно зарегистрированы на мероприятие. Проверьте почту, мы отправили вам всю информацию туда.

+

Спасибо за регистрацию!

+
+
+
+
+
+ + \ No newline at end of file diff --git a/EventVisitor/EventVisitorClientApp/Views/Home/ResultRegistration.cshtml.cs b/EventVisitor/EventVisitorClientApp/Views/Home/ResultRegistration.cshtml.cs new file mode 100644 index 0000000..dbab918 --- /dev/null +++ b/EventVisitor/EventVisitorClientApp/Views/Home/ResultRegistration.cshtml.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace EventVisitorClientApp.Views.Home +{ + public class ResultRegistrationModel : PageModel + { + public void OnGet() + { + } + } +} diff --git a/EventVisitor/EventVisitorClientApp/Views/Home/ViewEvent.cshtml b/EventVisitor/EventVisitorClientApp/Views/Home/ViewEvent.cshtml index 0e3b9d9..b3aa7bb 100644 --- a/EventVisitor/EventVisitorClientApp/Views/Home/ViewEvent.cshtml +++ b/EventVisitor/EventVisitorClientApp/Views/Home/ViewEvent.cshtml @@ -51,7 +51,7 @@
- + Страница с регистрацией
diff --git a/EventVisitor/EventVisitorDatabase/Entities/VisitorEntity.cs b/EventVisitor/EventVisitorDatabase/Entities/VisitorEntity.cs index 39cfb18..47745e8 100644 --- a/EventVisitor/EventVisitorDatabase/Entities/VisitorEntity.cs +++ b/EventVisitor/EventVisitorDatabase/Entities/VisitorEntity.cs @@ -32,7 +32,7 @@ namespace EventVisitorDatabase.Entities } return new VisitorEntity() { - Id = (int)model.Id, + Id = model.Id, Name = model.Name, Phone = model.Phone, Email = model.Email, diff --git a/EventVisitor/EventVisitorDatabase/Implements/VisitorStorage.cs b/EventVisitor/EventVisitorDatabase/Implements/VisitorStorage.cs index c3459c2..9993adc 100644 --- a/EventVisitor/EventVisitorDatabase/Implements/VisitorStorage.cs +++ b/EventVisitor/EventVisitorDatabase/Implements/VisitorStorage.cs @@ -29,14 +29,14 @@ namespace EventVisitorDatabase.Implements public VisitorViewModel? GetElement(VisitorBindingModel model) { - if (!model.Id.HasValue) + if (model.Id < 0) { return null; } using var context = new EventVisitorDbContext(); return context.Visitors. Include(x => x.Event). - FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))? + FirstOrDefault(x => (x.Id == model.Id))? .GetViewModel; } diff --git a/EventVisitor/EventVisitorLogic/BindingModels/VisitorBindingModel.cs b/EventVisitor/EventVisitorLogic/BindingModels/VisitorBindingModel.cs index 2ee62c1..cb2c552 100644 --- a/EventVisitor/EventVisitorLogic/BindingModels/VisitorBindingModel.cs +++ b/EventVisitor/EventVisitorLogic/BindingModels/VisitorBindingModel.cs @@ -9,7 +9,7 @@ namespace EventVisitorLogic.BindingModels { public class VisitorBindingModel: IVisitorModel { - public int? Id { get; set; } + public int Id { get; set; } public string Name { get; set; } = string.Empty; public string Phone { get; set; } = string.Empty; public string Email { get; set; } = string.Empty; diff --git a/EventVisitor/EventVisitorLogic/Logic/VisitorLogic.cs b/EventVisitor/EventVisitorLogic/Logic/VisitorLogic.cs index 893d0cb..889535e 100644 --- a/EventVisitor/EventVisitorLogic/Logic/VisitorLogic.cs +++ b/EventVisitor/EventVisitorLogic/Logic/VisitorLogic.cs @@ -91,7 +91,7 @@ namespace EventVisitorLogic.Logic { throw new ArgumentNullException("Нет почты", nameof(model.Email)); } - if (model.DayBirth <= DateTime.Now) + if (model.DayBirth >= DateTime.Now) { throw new ArgumentNullException("Неверная дата рождения", nameof(model.DayBirth)); } diff --git a/EventVisitor/EventVisitorRestApi/Controllers/MainController.cs b/EventVisitor/EventVisitorRestApi/Controllers/MainController.cs index a8f3dc2..0b97d13 100644 --- a/EventVisitor/EventVisitorRestApi/Controllers/MainController.cs +++ b/EventVisitor/EventVisitorRestApi/Controllers/MainController.cs @@ -53,6 +53,19 @@ namespace EventVisitorRestApi.Controllers } } + [HttpPost] + public void RegistrationOnEvent(VisitorBindingModel model) + { + try + { + _visitor.Create(model); + } + catch (Exception ex) + { + throw; + } + } + //[HttpGet]