формы клиента

This commit is contained in:
Allllen4a 2024-05-01 18:15:54 +04:00
parent 8f0a0d1491
commit b65a2539c5
15 changed files with 463 additions and 19 deletions

View File

@ -0,0 +1,68 @@
using BeautySalonContracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace BeutySalonClientApp
{
public class APIClient
{
private static readonly HttpClient _client = new();
public static ClientViewModel? Client { 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;
Console.WriteLine(requestUrl);
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);
}
}
public static O? PostRequestWithResult<I, O>(string requestUrl, I 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)
{
return JsonConvert.DeserializeObject<O>(result);
}
else
{
return default;
}
}
}
}

View File

@ -0,0 +1,19 @@
@{
ViewData["Title"] = "Вход";
}
<h4 class="fw-bold">Вход в приложение</h4>
<form method="post">
<div class="mb-3">
<label for="login" class="form-label">Логин:</label>
<input id="login" name="login" type="text" class="form-control" aria-label="Login">
</div>
<div class="mb-3">
<label for="password" class="form-label">Пароль:</label>
<input id="password" name="password" type="password" class="form-control" aria-label="Password">
</div>
<button type="submit" class="btn button-primary">
Войти
</button>
</form>

View File

@ -29,7 +29,7 @@
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.Evaluation)
@foreach (var item in ViewBag.Rating)
{
<tr class="table-row" id="row-@item.Id">
<td>@item.PointsProcedure</td>

View File

@ -1,4 +1,5 @@
@{

@{
ViewData["Title"] = "FormationDinner";
}

View File

@ -1,8 +1,8 @@
@{
ViewData["Title"] = "Home Page";
ViewData["Title"] = "HomePage";
}
<h1 class="display-4 text-center">Мы Вас не ждали, зло пожаловать!</h1>
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
<p><img src="https://sun9-57.userapi.com/impg/U8tTT9S9N-zD2N-mpGTwGrYjGCCC1F2-vUHL8Q/1qx0OUofgWw.jpg?size=997x740&quality=96&sign=645bdc6ab2131ec3f222673cddd4e02b&type=album" alt="Logo" /></p>
</div>

View File

@ -1,6 +0,0 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -0,0 +1,25 @@
@{
ViewData["Title"] = "Регистрация";
}
<h4 class="fw-bold">Регистрация</h4>
<form method="post">
<div class="mb-3">
<label for="login" class="form-label">Логин:</label>
<input id="login" name="login" type="text" class="form-control" aria-label="Login">
</div>
<div class="mb-3">
<label for="password" class="form-label">Пароль:</label>
<input id="password" name="password" type="password" class="form-control" aria-label="Password">
</div>
<div class="mb-3">
<label for="email" class="form-label">Адрес электронной почты:</label>
<input id="email" name="email" type="email" class="form-control" aria-label="Email">
</div>
<div>
<button type="submit" class="btn button-primary">
Регистрация
</button>
</div>
</form>

View File

@ -0,0 +1,75 @@
@{
ViewData["Title"] = "Заказ";
}
<h4 class="fw-bold">Создать заказ</h4>
<p class="mb-0 fw-bold">Выбранные услуги:</p>
<div>
<table class="table mb-0">
<thead>
<tr>
<th>Название</th>
<th>Стоимость</th>
<th>Количество</th>
<th></th>
</tr>
</thead>
<tbody id="service-tbody">
<tr>
<td>Не выбрано</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<p class="mb-0 fw-bold">Добавить услугу:</p>
<p class="mb-0">Наименование:</p>
<select class="form-select mb-0" id="service-select"></select>
<p class="mb-0">Количество:</p>
<input type="number" min="1" value="1" id="service-count-input" class="form-control mb-2" />
<button id="add-service-button" class="button-primary">
Добавить
</button>
<p class="mb-0 fw-bold">Выбранные процедуры:</p>
<div>
<table class="table mb-0">
<thead>
<tr>
<th>Название</th>
<th>Стоимость</th>
<th>Количество</th>
<th></th>
</tr>
</thead>
<tbody id="procedure-tbody">
<tr>
<td>Не выбрано</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<p class="mb-0 fw-bold">Привязать процедуру:</p>
<p class="mb-0">Наименование:</p>
<select class="form-select mb-0" id="procedure-select"></select>
<p class="mb-0">Количество:</p>
<input type="number" min="1" value="1" id="procedure-count-input" class="form-control mb-2" />
<button id="add-procedure-button" class="button-primary">
Привязать
</button>
<p class="mb-0 fw-bold">Стоимость заказа:</p>
<input type="number" step="0.01" id="price-input" class="form-control mb-2" value="0.01" readonly />
<button id="create-button" class="button-primary">
Создать
</button>
<script src="~/js/order-create.js" asp-append-version="true"></script>

View File

@ -0,0 +1,77 @@
@{
ViewData["Title"] = "Заказ";
}
<h4 class="fw-bold">Обновить заказ</h4>
<p class="mb-0 fw-bold">Выбранные услуги:</p>
<div>
<table class="table mb-0">
<thead>
<tr>
<th>Название</th>
<th>Стоимость</th>
<th>Количество</th>
<th></th>
</tr>
</thead>
<tbody id="service-tbody">
<tr>
<td>Не выбрано</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<p class="mb-0 fw-bold">Добавить услугу:</p>
<p class="mb-0">Наименование:</p>
<select class="form-select mb-0" id="service-select"></select>
<p class="mb-0">Количество:</p>
<input type="number" min="1" value="1" id="service-count-input" class="form-control mb-2" />
<button id="add-service-button" class="button-primary">
Добавить
</button>
<p class="mb-0 fw-bold">Выбранные процедуры:</p>
<div>
<table class="table mb-0">
<thead>
<tr>
<th>Название</th>
<th>Стоимость</th>
<th>Количество</th>
<th></th>
</tr>
</thead>
<tbody id="procedure-tbody">
<tr>
<td>Не выбрано</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<p class="mb-0 fw-bold">Добавить процедуру:</p>
<p class="mb-0">Наименование:</p>
<select class="form-select mb-0" id="procedure-select"></select>
<p class="mb-0">Количество:</p>
<input type="number" min="1" value="1" id="procedure-count-input" class="form-control mb-2" />
<button id="add-procedure-button" class="button-primary">
Добавить
</button>
<p class="mb-0 fw-bold">Стоимость заказа:</p>
<input type="number" step="0.01" id="price-input" class="form-control mb-2" value="0.01" readonly />
<button id="update-button" class="button-primary">
Обновить
</button>
<input id="id" value="@ViewBag.Id" style="display: none;" />
<script src="~/js/order-update.js" asp-append-version="true"></script>

View File

@ -0,0 +1,49 @@
@{
ViewData["Title"] = "Процедура";
}
<h4 class="fw-bold">Создать процедуру</h4>
<p class="mb-0">Название процедуры:</p>
<input id="name-input" class="form-control mb-2" />
<p class="mb-0 fw-bold">Выбранная косметика:</p>
<div>
<table class="table mb-0">
<thead>
<tr>
<th>Бренд</th>
<th>Наименование косметики</th>
<th>Стоимость</th>
<th>Количество</th>
<th></th>
</tr>
</thead>
<tbody id="tbody">
<tr>
<td>Не выбрано</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<p class="mb-0 fw-bold">Добавить косметику:</p>
<p class="mb-0">Наименование:</p>
<select class="form-select mb-0" id="cosmetic-select"></select>
<p class="mb-0">Количество:</p>
<input type="number" min="1" value="1" id="count-input" class="form-control mb-2" />
<button id="add-button" class="button-primary">
Добавить
</button>
<p class="mb-0 fw-bold">Стоимость процедуры:</p>
<input type="number" step="0.01" id="price-input" class="form-control mb-2" value="0.01" readonly />
<button id="create-button" class="button-primary">
Создать
</button>
<script src="~/js/procedure-create.js" asp-append-version="true"></script>

View File

@ -0,0 +1,51 @@
@{
ViewData["Title"] = "Процедура";
}
<h4 class="fw-bold">Обновить процедуру</h4>
<p class="mb-0">Название процедуры:</p>
<input id="name-input" class="form-control mb-2" />
<p class="mb-0 fw-bold">Выбранная косметика:</p>
<div>
<table class="table mb-0">
<thead>
<tr>
<th>Бренд</th>
<th>Наименование косметики</th>
<th>Стоимость</th>
<th>Количество</th>
<th></th>
</tr>
</thead>
<tbody id="tbody">
<tr>
<td>Не выбрано</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<p class="mb-0 fw-bold">Добавить косметику:</p>
<p class="mb-0">Наименование:</p>
<select class="form-select mb-0" id="cosmetic-select"></select>
<p class="mb-0">Количество:</p>
<input type="number" min="1" value="1" id="count-input" class="form-control mb-2" />
<button id="add-button" class="button-primary">
Добавить
</button>
<p class="mb-0 fw-bold">Стоимость процедуры:</p>
<input type="number" step="0.01" id="price-input" class="form-control mb-2" value="0.01" readonly />
<button id="update-button" class="button-primary">
Обновить
</button>
<input id="id" value="@ViewBag.Id" style="display: none;" />
<script src="~/js/procedure-update.js" asp-append-version="true"></script>

View File

@ -0,0 +1,25 @@
@{
ViewData["Title"] = "Оценка";
}
<h4 class="fw-bold">Создать оценку</h4>
<form method="post" asp-controller="Rating" asp-action="Create">
<p class="mb-0">Баллы за процедуру:</p>
<input type="number" min="0" max="10" step="0.01" name="pointsProcedure" class="form-control mb-2" />
<p class="mb-0">Баллы за косметику:</p>
<input type="number" min="0" max="10" step="0.01" name="pointsCosmetics" class="form-control mb-2" />
<p class="mb-0">Процедура:</p>
<select class="form-select mb-2" name="procedureId">
@foreach (var procedure in @ViewBag.Procedure)
{
<option value="@procedure.Id">
@(procedure.ProcedureName); @(procedure.ProcedurePrice) р.
</option>
}
</select>
<button class="button-primary text-button">
Создать
</button>
</form>

View File

@ -0,0 +1,38 @@
@{
ViewData["Title"] = "Оценка";
}
<h4 class="fw-bold">Обновить оценку</h4>
<form method="post" asp-controller="Rating" asp-action="Create">
<input name="id" value="@ViewBag.Rating.Id" style="display: none;" />
<p class="mb-0">Баллы за процедуру:</p>
<input type="number" min="0" max="10" step="0.01" name="pointsProcedure" class="form-control mb-2"
value="@ViewBag.Rating.PointsProcedure.ToString("0.00").Replace(",", ".")" />
<p class="mb-0">Баллы за косметику:</p>
<input type="number" min="0" max="10" step="0.01" name="pointsCosmetics" class="form-control mb-2"
value="@ViewBag.Rating.PointsCosmetics.ToString("0.00").Replace(",", ".")" />
<p class="mb-0">Процедура:</p>
<select class="form-select mb-2" name="procedureId">
@foreach (var procedure in @ViewBag.Procedure)
{
@if (procedure.Id == ViewBag.Rating.ProcedureId)
{
<option value="@procedure.Id" selected>
@(procedure.ProcedureName); @(procedure.ProcedurePrice) р.
</option>
}
else
{
<option value="@procedure.Id">
@(procedure.ProcedureName); @(procedure.ProcedurePrice) р.
</option>
}
}
</select>
<button class="button-primary text-button">
Обновить
</button>
</form>
<script src="~/js/rating.js" asp-append-version="true"></script>

View File

@ -3,16 +3,22 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - ClientWebApp</title>
<title>@ViewData["Title"] - BeutySalonClientApp</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="~/ClientWebApp.styles.css" asp-append-version="true" />
<link rel="stylesheet" href="~/BeutySalonClientApp.styles.css" asp-append-version="true" />
</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">ClientWebApp</a>
<div class="d-flex flex-column">
<a class="navbar-brand fw-weight-bold py-0 px-2" asp-area="" asp-controller="Home" asp-action="Index">Вы Ужасны</a>
<div class="px-2">ClientApp</div>
</div>
<div class="mx-2">
<img src="https://png.pngtree.com/png-clipart/20191120/original/pngtree-spider-glyph-icon-vector-png-image_5056646.jpg" alt="mdo" width="35" height="35" class="rounded-circle">
</div>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -20,10 +26,25 @@
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<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="Home" asp-action="Register">Регистрация</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="Home" asp-action="Enter">Авторизация</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Procedure">Процедуры</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Order">Заказы</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Rating">Оценки</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ServiceList">Список</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Report">Отчет</a>
</li>
</ul>
</div>
@ -38,7 +59,7 @@
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2024 - ClientWebApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
&copy; 2023 - BeutySalonClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>

View File

@ -5,5 +5,6 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"IPAddress": "http://localhost:5277/"
}