From 47a6cd86a616bb0a0316a3286b9243ca2cb486bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=20=D0=94?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=BB=D0=BE=D0=B2?= Date: Wed, 1 May 2024 04:28:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=AD=D1=85=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VeterinaryClinicWebApp/APIClient.cs | 49 +++++++++ .../VeterinaryClinicWebApp.csproj | 11 ++ .../Views/Animal/Animals.cshtml | 69 ++++++++++++ .../Views/Animal/CreateAnimal.cshtml | 45 ++++++++ .../Views/Animal/UpdateAnimal.cshtml | 52 +++++++++ .../Views/Home/Enter.cshtml | 27 +++++ .../Views/Home/Index.cshtml | 3 +- .../Views/Home/Privacy.cshtml | 53 +++++++++- .../Views/Home/Register.cshtml | 56 ++++++++++ .../Views/Shared/_Layout.cshtml | 100 ++++++++++++------ .../VeterinaryClinicWebApp/appsettings.json | 4 +- 11 files changed, 426 insertions(+), 43 deletions(-) create mode 100644 VeterinaryClinic/VeterinaryClinicWebApp/APIClient.cs create mode 100644 VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/Animals.cshtml create mode 100644 VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/CreateAnimal.cshtml create mode 100644 VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/UpdateAnimal.cshtml create mode 100644 VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Enter.cshtml create mode 100644 VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Register.cshtml diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/APIClient.cs b/VeterinaryClinic/VeterinaryClinicWebApp/APIClient.cs new file mode 100644 index 0000000..e924ba4 --- /dev/null +++ b/VeterinaryClinic/VeterinaryClinicWebApp/APIClient.cs @@ -0,0 +1,49 @@ +using VeterinaryClinicContracts.ViewModels; +using Newtonsoft.Json; +using System.Net.Http.Headers; +using System.Text; + +namespace VeterinaryClinicWebApp +{ + public static class APIClient + { + private static readonly HttpClient _client = new(); + public static UserViewModel? User { get; set; } = null; + + public static void Connect(IConfiguration configuration) + { + _client.BaseAddress = new Uri(configuration["IPAddress"]); + _client.DefaultRequestHeaders.Accept.Clear(); + _client.DefaultRequestHeaders.Accept.Add(new + MediaTypeWithQualityHeaderValue("application/json")); + } + + public static T? GetRequest(string requestUrl) + { + var response = _client.GetAsync(requestUrl); + var result = response.Result.Content.ReadAsStringAsync().Result; + if (response.Result.IsSuccessStatusCode) + { + return JsonConvert.DeserializeObject(result); + } + else + { + throw new Exception(result); + } + } + + public static void PostRequest(string requestUrl, T model) + { + var json = JsonConvert.SerializeObject(model); + var data = new StringContent(json, Encoding.UTF8, "application/json"); + + var response = _client.PostAsync(requestUrl, data); + + var result = response.Result.Content.ReadAsStringAsync().Result; + if (!response.Result.IsSuccessStatusCode) + { + throw new Exception(result); + } + } + } +} diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/VeterinaryClinicWebApp.csproj b/VeterinaryClinic/VeterinaryClinicWebApp/VeterinaryClinicWebApp.csproj index 620ac26..d839275 100644 --- a/VeterinaryClinic/VeterinaryClinicWebApp/VeterinaryClinicWebApp.csproj +++ b/VeterinaryClinic/VeterinaryClinicWebApp/VeterinaryClinicWebApp.csproj @@ -6,6 +6,10 @@ enable + + + + @@ -13,4 +17,11 @@ + + + + + + + diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/Animals.cshtml b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/Animals.cshtml new file mode 100644 index 0000000..169e056 --- /dev/null +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/Animals.cshtml @@ -0,0 +1,69 @@ + +@using VeterinaryClinicContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "Животные"; +} + +
+

Животные

+
+ +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } + +

+ Создать животного +

+ + + + + + + + + + + + + + @foreach (var animal in Model) + { + + + + + + + + + + } + +
НомерВидПородаВозрастПользователь
@Html.DisplayFor(modelItem => animal.Id)@Html.DisplayFor(modelItem => animal.Type)@Html.DisplayFor(modelItem => animal.Breed)@Html.DisplayFor(modelItem => animal.Age)@Html.DisplayFor(modelItem => animal.UserFullName) +

+
+

+
+ } +
+ +@section scripts { + +} diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/CreateAnimal.cshtml b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/CreateAnimal.cshtml new file mode 100644 index 0000000..278e32f --- /dev/null +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/CreateAnimal.cshtml @@ -0,0 +1,45 @@ +@{ + ViewData["Title"] = "Создание животного"; +} + +
+

Создание животного

+
+ +
+ +
+
Вид:
+
+
+ + +
+
Порода:
+
+
+ +
+
Возраст:
+
+
+ + +
+
Медикаменты:
+
+ +
+
+ + +
+
+
+
+
diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/UpdateAnimal.cshtml b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/UpdateAnimal.cshtml new file mode 100644 index 0000000..d04c086 --- /dev/null +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Animal/UpdateAnimal.cshtml @@ -0,0 +1,52 @@ + +@using VeterinaryClinicContracts.ViewModels + +@model AnimalViewModel + +@{ + ViewData["Title"] = "Редактирование животного"; +} + +
+

Редактирование животного

+
+ +
+ +
+
Вид:
+
+
+ + +
+
Порода:
+
+
+ + +
+
Возраст:
+
+
+ + +
+
Медикаменты:
+
+ +
+
+ + +
+
+
+
+
diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Enter.cshtml b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Enter.cshtml new file mode 100644 index 0000000..f43460a --- /dev/null +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Enter.cshtml @@ -0,0 +1,27 @@ +@{ + ViewData["Title"] = "Вход"; +} + +
+

Вход в приложение

+
+ +
+ +
+
Логин:
+
+
+ + +
+
Пароль:
+
+
+ + +
+
+
+
+
diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Index.cshtml b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Index.cshtml index bcfd79a..f43ef32 100644 --- a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Index.cshtml +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Index.cshtml @@ -3,6 +3,5 @@ }
-

Welcome

-

Learn about building Web apps with ASP.NET Core.

+

Welcome to my progect

diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Privacy.cshtml b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Privacy.cshtml index af4fb19..675660f 100644 --- a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Privacy.cshtml +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Privacy.cshtml @@ -1,6 +1,49 @@ -@{ - ViewData["Title"] = "Privacy Policy"; -} -

@ViewData["Title"]

+@using VeterinaryClinicContracts.ViewModels -

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

+@model UserViewModel + +@{ + ViewData["Title"] = "Личные данные"; +} + +
+

Личные данные

+
+ +
+ +
+
ФИО:
+
+
+ + +
+
Телефон:
+
+
+ + +
+
Роль:
+
+
+ + +
+
Логин:
+
+
+ + +
+
Пароль:
+
+
+ + +
+
+
+
+
\ No newline at end of file diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Register.cshtml b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Register.cshtml new file mode 100644 index 0000000..c310e26 --- /dev/null +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Home/Register.cshtml @@ -0,0 +1,56 @@ +@using VeterinaryClinicDataModels.Enums + +@{ + ViewData["Title"] = "Регистрация"; +} + +
+

Регистрация

+
+ +
+ +
+
ФИО:
+
+
+ + +
+
Роль:
+
+ +
+
+ + +
+
Телефон:
+
+
+ + +
+
Логин:
+
+
+ + +
+
Пароль:
+
+
+ + +
+
+
+
+
+ diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Shared/_Layout.cshtml b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Shared/_Layout.cshtml index b724a26..a2dde66 100644 --- a/VeterinaryClinic/VeterinaryClinicWebApp/Views/Shared/_Layout.cshtml +++ b/VeterinaryClinic/VeterinaryClinicWebApp/Views/Shared/_Layout.cshtml @@ -5,45 +5,75 @@ @ViewData["Title"] - VeterinaryClinicWebApp - - + -
- -
-
-
+
+ +
+
+
@RenderBody() -
+
+
+
+
+ © 2024 - Айболит - Privacy
+
-
-
- © 2024 - VeterinaryClinicWebApp - Privacy -
-
- - - - @await RenderSectionAsync("Scripts", required: false) + + + + + @await RenderSectionAsync("Scripts", required: false) diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/appsettings.json b/VeterinaryClinic/VeterinaryClinicWebApp/appsettings.json index 10f68b8..238f900 100644 --- a/VeterinaryClinic/VeterinaryClinicWebApp/appsettings.json +++ b/VeterinaryClinic/VeterinaryClinicWebApp/appsettings.json @@ -5,5 +5,7 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + + "IPAddress": "http://localhost:5159/" }