From a7ea872d308714be53ce52530fad10a3f6e50bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=BD=D0=B0=20=D0=97=D0=B0=D0=B1=D1=80=D0=BE?= =?UTF-8?q?=D0=B4=D0=B8=D0=BD=D0=B0?= Date: Sun, 31 Mar 2024 13:06:09 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F,=20=D0=B2=D1=85=D0=BE=D0=B4=20=D0=B8?= =?UTF-8?q?=20=D0=BB=D0=B8=D1=87=D0=BD=D1=8B=D0=B5=20=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 44 ++++++++- .../HotelOrganiserApp/Views/Home/Enter.cshtml | 39 ++++++++ .../HotelOrganiserApp/Views/Home/Index.cshtml | 8 +- .../Views/Home/Privacy.cshtml | 92 ++++++++++++++++++- .../Views/Home/Register.cshtml | 74 +++++++++++++++ .../Views/Shared/_Layout.cshtml | 61 ++++++------ 6 files changed, 281 insertions(+), 37 deletions(-) create mode 100644 Hotel/HotelOrganiserApp/Views/Home/Enter.cshtml create mode 100644 Hotel/HotelOrganiserApp/Views/Home/Register.cshtml diff --git a/Hotel/HotelOrganiserApp/Controllers/HomeController.cs b/Hotel/HotelOrganiserApp/Controllers/HomeController.cs index 8806fd1..d0c5250 100644 --- a/Hotel/HotelOrganiserApp/Controllers/HomeController.cs +++ b/Hotel/HotelOrganiserApp/Controllers/HomeController.cs @@ -1,4 +1,6 @@ -using HotelOrganiserApp.Models; +using HotelContracts.BindingModels; +using HotelContracts.ViewModels; +using HotelOrganiserApp.Models; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; @@ -15,6 +17,10 @@ namespace HotelOrganiserApp.Controllers public IActionResult Index() { + if (APIClient.Organiser == null) + { + return Redirect("~/Home/Enter"); + } return View(); } @@ -23,11 +29,47 @@ namespace HotelOrganiserApp.Controllers return View(); } + [HttpPost] + public void Register(string login, string email, string password, string surname, string name, string patronymic, string telephone) + { + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(patronymic)) + { + throw new Exception("Введите логин, пароль, фамилию, имя и отчество"); + } + APIClient.PostRequest("api/organiser/register", new OrganiserBindingModel + { + OrganiserSurname = surname, + OrganiserName = name, + OrganiserPatronymic = patronymic, + OrganiserLogin = login, + OrganiserPassword = password, + OrganiserEmail = email, + OrganiserPhoneNumber = telephone + }); + + Response.Redirect("Enter"); + return; + } + public IActionResult Enter() { return View(); } + public void Enter(string login, string password) + { + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите логин и пароль"); + } + APIClient.Organiser = APIClient.GetRequest($"api/organiser/login?login={login}&password={password}"); + if (APIClient.Organiser == null) + { + throw new Exception("Неверный логин/пароль"); + } + Response.Redirect("Index"); + } + public IActionResult Report() { return View(); diff --git a/Hotel/HotelOrganiserApp/Views/Home/Enter.cshtml b/Hotel/HotelOrganiserApp/Views/Home/Enter.cshtml new file mode 100644 index 0000000..b6bf1a1 --- /dev/null +++ b/Hotel/HotelOrganiserApp/Views/Home/Enter.cshtml @@ -0,0 +1,39 @@ +@{ + ViewData["Title"] = "Enter"; +} + +
+
+
+
+
+
+
+
+

Вход

+
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/Hotel/HotelOrganiserApp/Views/Home/Index.cshtml b/Hotel/HotelOrganiserApp/Views/Home/Index.cshtml index d2d19bd..2a047a1 100644 --- a/Hotel/HotelOrganiserApp/Views/Home/Index.cshtml +++ b/Hotel/HotelOrganiserApp/Views/Home/Index.cshtml @@ -3,6 +3,10 @@ }
-

Welcome

-

Learn about building Web apps with ASP.NET Core.

+
+
+

Hotel

+

Курсовая работа. Исполнитель

+
+
diff --git a/Hotel/HotelOrganiserApp/Views/Home/Privacy.cshtml b/Hotel/HotelOrganiserApp/Views/Home/Privacy.cshtml index af4fb19..ee5e2e4 100644 --- a/Hotel/HotelOrganiserApp/Views/Home/Privacy.cshtml +++ b/Hotel/HotelOrganiserApp/Views/Home/Privacy.cshtml @@ -1,6 +1,88 @@ -@{ - ViewData["Title"] = "Privacy Policy"; -} -

@ViewData["Title"]

+@using HotelContracts.ViewModels -

Use this page to detail your site's privacy policy.

+@model OrganiserViewModel + +@{ + ViewData["Title"] = "Privacy"; +} +
+

Мои данны

+
+
+
+
+
+ + +
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/Hotel/HotelOrganiserApp/Views/Home/Register.cshtml b/Hotel/HotelOrganiserApp/Views/Home/Register.cshtml new file mode 100644 index 0000000..97f60cb --- /dev/null +++ b/Hotel/HotelOrganiserApp/Views/Home/Register.cshtml @@ -0,0 +1,74 @@ +@{ + ViewData["Title"] = "Register"; +} + +
+
+
+
+
+
+
+
+

Регистрация

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/Hotel/HotelOrganiserApp/Views/Shared/_Layout.cshtml b/Hotel/HotelOrganiserApp/Views/Shared/_Layout.cshtml index 576c53e..0108d73 100644 --- a/Hotel/HotelOrganiserApp/Views/Shared/_Layout.cshtml +++ b/Hotel/HotelOrganiserApp/Views/Shared/_Layout.cshtml @@ -17,39 +17,42 @@ aria-expanded="false" aria-label="Toggle navigation"> -