Эхх
This commit is contained in:
parent
3e4fa91beb
commit
47a6cd86a6
49
VeterinaryClinic/VeterinaryClinicWebApp/APIClient.cs
Normal file
49
VeterinaryClinic/VeterinaryClinicWebApp/APIClient.cs
Normal file
@ -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<T>(string requestUrl)
|
||||
{
|
||||
var response = _client.GetAsync(requestUrl);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static void PostRequest<T>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,10 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VeterinaryClinicBusinessLogics\VeterinaryClinicBusinessLogics.csproj" />
|
||||
<ProjectReference Include="..\VeterinaryClinicContracts\VeterinaryClinicContracts.csproj" />
|
||||
@ -13,4 +17,11 @@
|
||||
<ProjectReference Include="..\VeterinaryClinicDataModels\VeterinaryClinicDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Views\Visit\" />
|
||||
<Folder Include="Views\Vaccination\" />
|
||||
<Folder Include="Views\Service\" />
|
||||
<Folder Include="Views\Medication\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -0,0 +1,69 @@
|
||||
|
||||
@using VeterinaryClinicContracts.ViewModels
|
||||
|
||||
@model List<AnimalViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Животные";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Животные</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateAnimal">Создать животного</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Номер</th>
|
||||
<th>Вид</th>
|
||||
<th>Порода</th>
|
||||
<th>Возраст</th>
|
||||
<th>Пользователь</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach (var animal in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.DisplayFor(modelItem => animal.Id)</td>
|
||||
<td>@Html.DisplayFor(modelItem => animal.Type)</td>
|
||||
<td>@Html.DisplayFor(modelItem => animal.Breed)</td>
|
||||
<td>@Html.DisplayFor(modelItem => animal.Age)</td>
|
||||
<td>@Html.DisplayFor(modelItem => animal.UserFullName)</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateAnimal", "/Animal", new { id = animal.Id })'">Изменить</button></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="deleteAnimal(@animal.Id)">Удалить</button></p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script>
|
||||
function deleteAnimal(id) {
|
||||
if (confirm("Вы уверены, что хотите удалить животного?")) {
|
||||
$.post('@Url.Action("DeleteAnimal", "/Animal")' + '/' + id, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание животного";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание животного</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Вид -->
|
||||
<div class="row">
|
||||
<div class="col-4">Вид:</div>
|
||||
<div class="col-8"><input type="text" name="type" id="type" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Порода -->
|
||||
<div class="row">
|
||||
<div class="col-4">Порода:</div>
|
||||
<div class="col-8"><input type="text" name="breed" id="breed" /></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Возраст:</div>
|
||||
<div class="col-8"><input type="text" name="Age" id="Age" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Пользователь -->
|
||||
<div class="row">
|
||||
<div class="col-4">Медикаменты:</div>
|
||||
<div class="col-8">
|
||||
<select name="medication" id="medication" class="form-control">
|
||||
@foreach (var medication in ViewBag.Medications)
|
||||
{
|
||||
<option value="@medication.Name"></option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Создать" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,52 @@
|
||||
|
||||
@using VeterinaryClinicContracts.ViewModels
|
||||
|
||||
@model AnimalViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Редактирование животного";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование животного</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Вид -->
|
||||
<div class="row">
|
||||
<div class="col-4">Вид:</div>
|
||||
<div class="col-8"><input type="text" name="type" value="@Model.Type" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Порода -->
|
||||
<div class="row">
|
||||
<div class="col-4">Порода:</div>
|
||||
<div class="col-8"><input type="text" class="form-control" name="breed" value="@Model.Breed" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Возраст -->
|
||||
<div class="row">
|
||||
<div class="col-4">Возраст:</div>
|
||||
<div class="col-8"><input type="text" name="age" value="@Model.Age" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Медикаменты -->
|
||||
<div class="row">
|
||||
<div class="col-4">Медикаменты:</div>
|
||||
<div class="col-8">
|
||||
<select name="medication" id="medication" class="form-control" size="4" multiple>
|
||||
@foreach (var medication in ViewBag.Medications)
|
||||
{
|
||||
var isSelected = Model.AnimalMedications.Any(x => x.Key.Equals(medication.Id));
|
||||
<option value="@medication.Id" selected="@isSelected" >@medication.Name</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Сохранить" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,27 @@
|
||||
@{
|
||||
ViewData["Title"] = "Вход";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Вход в приложение</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Логин -->
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8"><input type="text" name="email" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Пароль -->
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Вход" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -3,6 +3,5 @@
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Welcome</h1>
|
||||
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
|
||||
<h1 class="display-4">Welcome to my progect</h1>
|
||||
</div>
|
||||
|
@ -1,6 +1,49 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
@using VeterinaryClinicContracts.ViewModels
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
@model UserViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Личные данные";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Личные данные</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- ФИО -->
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8"><input type="text" name="fullname" value="@Model.FullName" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Телефон -->
|
||||
<div class="row">
|
||||
<div class="col-4">Телефон:</div>
|
||||
<div class="col-8"><input type="text" name="phone" value="@Model.Phone" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Должность -->
|
||||
<div class="row">
|
||||
<div class="col-4">Роль:</div>
|
||||
<div class="col-8"><input type="text" name="role" value="@Model.Role" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Логин -->
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8"><input type="text" name="email" value="@Model.Email" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Пароль -->
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" value="@Model.Password" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Сохранить" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,56 @@
|
||||
@using VeterinaryClinicDataModels.Enums
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Регистрация";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- ФИО -->
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8"><input type="text" name="fullname" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Роль -->
|
||||
<div class="row">
|
||||
<div class="col-4">Роль:</div>
|
||||
<div class="col-8">
|
||||
<select name="role">
|
||||
<option id="@UserRole.Неизвестный" value="@UserRole.Неизвестный" selected>Неизвестный</option>
|
||||
<option id="@UserRole.Администратор" value="@UserRole.Администратор">Администратор</option>
|
||||
<option id="@UserRole.Работник" value="@UserRole.Работник">Работник</option>
|
||||
<option id="@UserRole.Кладовщик" value="@UserRole.Кладовщик">Кладовщик</option>
|
||||
<option id="@UserRole.Клиент" value="@UserRole.Клиент">Клиент</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Телефон -->
|
||||
<div class="row">
|
||||
<div class="col-4">Телефон:</div>
|
||||
<div class="col-8"><input type="text" name="phone" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Логин -->
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8"><input type="text" name="email" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Пароль -->
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопка "Регистрация" -->
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -5,25 +5,54 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - VeterinaryClinicWebApp</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/VeterinaryClinicWebApp.styles.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/site.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">VeterinaryClinicWebApp</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Айболит</a>
|
||||
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-smrow-reverse">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<!-- Визиты -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Visit" asp-action="Visits">Пациенты</a>
|
||||
</li>
|
||||
<!-- Выписка визитов (привязка животных к визитам) -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Visit" asp-action="CreateVisitAnimals">Выписать визит</a>
|
||||
</li>
|
||||
<!-- Животные -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Animal" asp-action="Animals">Животные</a>
|
||||
</li>
|
||||
<!-- Прививки -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Vaccination" asp-action="Vaccinations">Прививки</a>
|
||||
</li>
|
||||
<!-- Услуги -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Service" asp-action="Services">Услуги</a>
|
||||
</li>
|
||||
<!-- Медикаменты -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Medication" asp-action="Medications">Медикаменты</a>
|
||||
</li>
|
||||
<!-- Личные данные -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</li>
|
||||
<!-- Вход -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
</li>
|
||||
<!-- Регистрация -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -35,15 +64,16 @@
|
||||
@RenderBody()
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - VeterinaryClinicWebApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
© 2024 - Айболит - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
@ -5,5 +5,7 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
|
||||
"IPAddress": "http://localhost:5159/"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user