From eaa284a40048d55f4a30028af289ba08dde38411 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?=
=?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com>
Date: Sun, 12 May 2024 19:04:40 +0400
Subject: [PATCH] 70%
---
.../BusinessLogics/ImplementerLogic.cs | 130 ++++++++++
.../BusinessLogics/OrderLogic.cs | 130 ++++++----
.../BusinessLogics/WorkModeling .cs | 139 +++++++++++
SushiBar/SushiBarClientApp/APIClient.cs | 16 +-
.../Controllers/HomeController.cs | 5 +-
SushiBar/SushiBarClientApp/Program.cs | 2 +-
.../Properties/launchSettings.json | 38 ++-
.../SushiBarClientApp.csproj | 26 +-
.../Views/Home/Create.cshtml | 94 ++++----
.../SushiBarClientApp/Views/Home/Enter.cshtml | 29 +--
.../SushiBarClientApp/Views/Home/Index.cshtml | 134 +++++------
.../Views/Home/Privacy.cshtml | 48 ++--
.../Views/Home/Register.cshtml | 40 ++-
.../Views/Shared/Error.cshtml | 2 +-
.../Views/Shared/_Layout.cshtml | 28 ++-
.../Views/Shared/_Layout.cshtml.css | 2 +-
SushiBar/SushiBarClientApp/appsettings.json | 5 +-
.../SushiBarClientApp/wwwroot/css/site.css | 4 -
SushiBar/SushiBarClientApp/wwwroot/js/site.js | 2 +-
.../jquery-validation-unobtrusive/LICENSE.txt | 29 +--
.../jquery.validate.unobtrusive.js | 11 +-
.../jquery.validate.unobtrusive.min.js | 13 +-
.../wwwroot/lib/jquery/LICENSE.txt | 19 +-
.../wwwroot/lib/jquery/dist/jquery.js | 227 +++++++++---------
.../wwwroot/lib/jquery/dist/jquery.min.js | 4 +-
.../wwwroot/lib/jquery/dist/jquery.min.map | 2 +-
.../BindingModels/ImplementerBindingModel.cs | 18 ++
.../BindingModels/OrderBindingModel.cs | 2 +
.../IImplementerLogic.cs | 20 ++
.../BusinessLogicsContracts/IOrderLogic.cs | 1 +
.../BusinessLogicsContracts/IWorkProcess.cs | 13 +
.../SearchModels/ImplementerSearchModel.cs | 15 ++
.../SearchModels/OrderSearchModel.cs | 8 +-
.../StoragesContracts/IImplementerStorage.cs | 21 ++
.../ViewModels/ImplementerViewModel.cs | 27 +++
.../ViewModels/OrderViewModel.cs | 4 +
.../Models/IImplementerModel.cs | 19 ++
.../Implements/ImplementerStorage.cs | 84 +++++++
.../Implements/OrderStorage.cs | 58 ++---
.../20240403125318_InitialCreate.Designer.cs | 171 -------------
.../Migrations/20240501085423_Add_client.cs | 68 ------
...ner.cs => 20240512150027_6Lab.Designer.cs} | 47 +++-
...nitialCreate.cs => 20240512150027_6Lab.cs} | 64 ++++-
.../SushiBarDatabaseModelSnapshot.cs | 43 ++++
.../Models/Implementer.cs | 70 ++++++
.../SushiBarDatabaseImplement/Models/Order.cs | 16 +-
.../SushiBarDatabase.cs | 2 +
.../DataFileSingleton.cs | 5 +
.../Implements/ImplementerStorage.cs | 99 ++++++++
.../Models/Implementer.cs | 87 +++++++
.../DataListSingleton.cs | 2 +
.../Implements/ImplementerStorage.cs | 123 ++++++++++
.../Models/Implementer.cs | 60 +++++
.../Controllers/ClientController.cs | 97 ++++----
.../Controllers/ImplementerController .cs | 107 +++++++++
.../Controllers/MainController.cs | 121 +++++-----
SushiBar/SushiBarRestApi/Program.cs | 24 +-
.../Properties/launchSettings.json | 20 +-
.../Properties/serviceDependencies.json | 3 -
.../Properties/serviceDependencies.local.json | 3 -
.../SushiBarRestApi/SushiBarRestApi.csproj | 30 +--
SushiBar/SushiBarRestApi/SushiBarRestApi.http | 6 -
SushiBar/SushiBarRestApi/log4net.config | 20 --
63 files changed, 1823 insertions(+), 934 deletions(-)
create mode 100644 SushiBar/SushiBarBusinessLogic/BusinessLogics/ImplementerLogic.cs
create mode 100644 SushiBar/SushiBarBusinessLogic/BusinessLogics/WorkModeling .cs
create mode 100644 SushiBar/SushiBarContracts/BindingModels/ImplementerBindingModel.cs
create mode 100644 SushiBar/SushiBarContracts/BusinessLogicsContracts/IImplementerLogic.cs
create mode 100644 SushiBar/SushiBarContracts/BusinessLogicsContracts/IWorkProcess.cs
create mode 100644 SushiBar/SushiBarContracts/SearchModels/ImplementerSearchModel.cs
create mode 100644 SushiBar/SushiBarContracts/StoragesContracts/IImplementerStorage.cs
create mode 100644 SushiBar/SushiBarContracts/ViewModels/ImplementerViewModel.cs
create mode 100644 SushiBar/SushiBarDataModels/Models/IImplementerModel.cs
create mode 100644 SushiBar/SushiBarDatabaseImplement/Implements/ImplementerStorage.cs
delete mode 100644 SushiBar/SushiBarDatabaseImplement/Migrations/20240403125318_InitialCreate.Designer.cs
delete mode 100644 SushiBar/SushiBarDatabaseImplement/Migrations/20240501085423_Add_client.cs
rename SushiBar/SushiBarDatabaseImplement/Migrations/{20240501085423_Add_client.Designer.cs => 20240512150027_6Lab.Designer.cs} (82%)
rename SushiBar/SushiBarDatabaseImplement/Migrations/{20240403125318_InitialCreate.cs => 20240512150027_6Lab.cs} (64%)
create mode 100644 SushiBar/SushiBarDatabaseImplement/Models/Implementer.cs
create mode 100644 SushiBar/SushiBarFileImplement/Implements/ImplementerStorage.cs
create mode 100644 SushiBar/SushiBarFileImplement/Models/Implementer.cs
create mode 100644 SushiBar/SushiBarListImplement/Implements/ImplementerStorage.cs
create mode 100644 SushiBar/SushiBarListImplement/Models/Implementer.cs
create mode 100644 SushiBar/SushiBarRestApi/Controllers/ImplementerController .cs
delete mode 100644 SushiBar/SushiBarRestApi/Properties/serviceDependencies.json
delete mode 100644 SushiBar/SushiBarRestApi/Properties/serviceDependencies.local.json
delete mode 100644 SushiBar/SushiBarRestApi/SushiBarRestApi.http
delete mode 100644 SushiBar/SushiBarRestApi/log4net.config
diff --git a/SushiBar/SushiBarBusinessLogic/BusinessLogics/ImplementerLogic.cs b/SushiBar/SushiBarBusinessLogic/BusinessLogics/ImplementerLogic.cs
new file mode 100644
index 0000000..eec660a
--- /dev/null
+++ b/SushiBar/SushiBarBusinessLogic/BusinessLogics/ImplementerLogic.cs
@@ -0,0 +1,130 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
+using SushiBarBusinessLogic.BusinessLogics;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarBusinessLogic
+{
+ public class ImplementerLogic : IImplementerLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IImplementerStorage _implementerStorage;
+
+ public ImplementerLogic(ILogger logger, IImplementerStorage implementerStorage)
+ {
+ _logger = logger;
+ _implementerStorage = implementerStorage;
+ }
+
+ public List? ReadList(ImplementerSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ImplementerFIO:{ImplementerFIO}.Password:{Password}.Id:{ Id}", model?.ImplementerFIO, model?.Password?.Length, model?.Id);
+ var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ImplementerFIO:{ImplementerFIO}.Password:{Password}.Id:{ Id}", model?.ImplementerFIO, model?.Password?.Length, model?.Id);
+ var element = _implementerStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+
+ public bool Create(ImplementerBindingModel model)
+ {
+ CheckModel(model);
+ if (_implementerStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool Update(ImplementerBindingModel model)
+ {
+ CheckModel(model);
+ if (_implementerStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool Delete(ImplementerBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_implementerStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ private void CheckModel(ImplementerBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
+ }
+ if (string.IsNullOrEmpty(model.Password))
+ {
+ throw new ArgumentNullException("Нет пароля исполнителя", nameof(model.Password));
+ }
+ if (model.WorkExperience < 0)
+ {
+ throw new ArgumentNullException("Стаж должен быть больше 0", nameof(model.WorkExperience));
+ }
+ if (model.Qualification < 0)
+ {
+ throw new ArgumentNullException("Квалификация должна быть положительной", nameof(model.Qualification));
+ }
+ _logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}.Password:{Password}.WorkExperience:{WorkExperience}.Qualification:{Qualification}.Id: { Id}",
+ model.ImplementerFIO, model.Password, model.WorkExperience, model.Qualification, model.Id);
+ var element = _implementerStorage.GetElement(new ImplementerSearchModel
+ {
+ ImplementerFIO = model.ImplementerFIO
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
+ }
+ }
+ }
+}
diff --git a/SushiBar/SushiBarBusinessLogic/BusinessLogics/OrderLogic.cs b/SushiBar/SushiBarBusinessLogic/BusinessLogics/OrderLogic.cs
index 3baee63..dd229c0 100644
--- a/SushiBar/SushiBarBusinessLogic/BusinessLogics/OrderLogic.cs
+++ b/SushiBar/SushiBarBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -12,7 +12,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
-
+ static readonly object _locker = new object();
public OrderLogic(ILogger logger, IOrderStorage orderStorage)
{
_logger = logger;
@@ -20,7 +20,8 @@ namespace SushiBarBusinessLogic.BusinessLogics
}
public List? ReadList(OrderSearchModel? model)
{
- _logger.LogInformation("Order. OrderID:{Id}", model?.Id);
+ _logger.LogInformation("ReadList. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}",
+ model?.ClientId, model?.Status, model?.ImplementerId, model?.DateFrom, model?.DateTo, model?.Id);
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
if (list == null)
{
@@ -30,24 +31,38 @@ namespace SushiBarBusinessLogic.BusinessLogics
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
-
public bool CreateOrder(OrderBindingModel model)
{
CheckModel(model);
if (model.Status != OrderStatus.Неизвестен)
- {
- _logger.LogWarning("Insert operation failed. Order status incorrect.");
return false;
- }
model.Status = OrderStatus.Принят;
if (_orderStorage.Insert(model) == null)
{
- model.Status = OrderStatus.Неизвестен;
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
+
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ lock (_locker)
+ {
+ return ChangeStatus(model, OrderStatus.Выполняется);
+ }
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Готов);
+ }
+
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Выдан);
+ }
+
private void CheckModel(OrderBindingModel model, bool withParams = true)
{
if (model == null)
@@ -58,62 +73,79 @@ namespace SushiBarBusinessLogic.BusinessLogics
{
return;
}
- if (model.SushiId < 0)
- {
- throw new ArgumentNullException("Некорректный идентификатор у суши", nameof(model.SushiId));
- }
if (model.Count <= 0)
{
- throw new ArgumentNullException("Количество суши в заказе должно быть больше 0", nameof(model.Count));
+ throw new ArgumentException("Колличество пиццы в заказе не может быть меньше 1", nameof(model.Count));
}
if (model.Sum <= 0)
{
- throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
+ throw new ArgumentException("Стоимость заказа на может быть меньше 1", nameof(model.Sum));
}
- _logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. SushiId: { SushiId}", model.Id, model.Sum, model.SushiId);
+ if (model.DateImplement.HasValue && model.DateImplement < model.DateCreate)
+ {
+ throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}");
+ }
+ _logger.LogInformation("Sushi. SushiId:{SushiId}.Count:{Count}.Sum:{Sum}Id:{Id}",
+ model.SushiId, model.Count, model.Sum, model.Id);
}
- public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
+ private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus)
{
- var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
- if (viewModel == null)
+ CheckModel(model, false);
+ var element = _orderStorage.GetElement(new OrderSearchModel()
+ {
+ Id = model.Id
+ });
+ if (element == null)
+ {
+ throw new InvalidOperationException(nameof(element));
+ }
+ model.DateCreate = element.DateCreate;
+ model.SushiId = element.SushiId;
+ model.DateImplement = element.DateImplement;
+ model.ClientId = element.ClientId;
+ if (!model.ImplementerId.HasValue)
+ {
+ model.ImplementerId = element.ImplementerId;
+ }
+ model.Status = element.Status;
+ model.Count = element.Count;
+ model.Sum = element.Sum;
+ if (requiredStatus - model.Status == 1)
+ {
+ model.Status = requiredStatus;
+ if (model.Status == OrderStatus.Готов)
+ {
+ model.DateImplement = DateTime.Now;
+ }
+ if (_orderStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ _logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus);
+ throw new InvalidOperationException($"Невозможно приствоить статус {requiredStatus} заказу с текущим статусом {model.Status}");
+
+ }
+
+ public OrderViewModel? ReadElement(OrderSearchModel model)
+ {
+ if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
- if (viewModel.Status + 1 != newStatus)
+ _logger.LogInformation("ReadElement. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}",
+ model.ClientId, model.Status, model.ImplementerId, model.DateFrom, model.DateTo, model.Id);
+ var element = _orderStorage.GetElement(model);
+ if (element == null)
{
- _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
- return false;
+ _logger.LogWarning("ReadElement element not found");
+ return null;
}
- model.Status = newStatus;
- if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now;
- else
- {
- model.DateImplement = viewModel.DateImplement;
- }
- CheckModel(model, false);
- if (_orderStorage.Update(model) == null)
- {
- model.Status--;
- _logger.LogWarning("Update operation failed");
- return false;
- }
- return true;
- }
-
- public bool TakeOrderInWork(OrderBindingModel model)
- {
- return StatusUpdate(model, OrderStatus.Выполняется);
- }
-
- public bool DeliveryOrder(OrderBindingModel model)
- {
- return StatusUpdate(model, OrderStatus.Выдан);
- }
-
- public bool FinishOrder(OrderBindingModel model)
- {
- return StatusUpdate(model, OrderStatus.Готов);
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
}
}
}
diff --git a/SushiBar/SushiBarBusinessLogic/BusinessLogics/WorkModeling .cs b/SushiBar/SushiBarBusinessLogic/BusinessLogics/WorkModeling .cs
new file mode 100644
index 0000000..14802a4
--- /dev/null
+++ b/SushiBar/SushiBarBusinessLogic/BusinessLogics/WorkModeling .cs
@@ -0,0 +1,139 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarBusinessLogic
+{
+ public class WorkModeling : IWorkProcess
+ {
+ private readonly ILogger _logger;
+
+ private readonly Random _rnd;
+
+ private IOrderLogic? _orderLogic;
+
+ public WorkModeling(ILogger logger)
+ {
+ _logger = logger;
+ _rnd = new Random(1000);
+ }
+
+ public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
+ {
+ _orderLogic = orderLogic;
+ var implementers = implementerLogic.ReadList(null);
+ if (implementers == null)
+ {
+ _logger.LogWarning("DoWork. Implementers is null");
+ return;
+ }
+ var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
+ if (orders == null || orders.Count == 0)
+ {
+ _logger.LogWarning("DoWork. Orders is null or empty");
+ return;
+ }
+ _logger.LogDebug("DoWork for {Count} orders", orders.Count);
+ foreach (var implementer in implementers)
+ {
+ Task.Run(() => WorkerWorkAsync(implementer, orders));
+ }
+ }
+
+ private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders)
+ {
+ if (_orderLogic == null || implementer == null)
+ {
+ return;
+ }
+ await RunOrderInWork(implementer);
+
+ await Task.Run(() =>
+ {
+ foreach (var order in orders)
+ {
+ try
+ {
+ _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
+ // пытаемся назначить заказ на исполнителя
+ _orderLogic.TakeOrderInWork(new OrderBindingModel
+ {
+ Id = order.Id,
+ ImplementerId = implementer.Id
+ });
+ // делаем работу
+ Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
+ _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
+ _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = order.Id
+ });
+ }
+ // кто-то мог уже перехватить заказ, игнорируем ошибку
+ catch (InvalidOperationException ex)
+ {
+ _logger.LogWarning(ex, "Error try get work");
+ }
+ // заканчиваем выполнение имитации в случае иной ошибки
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error while do work");
+ throw;
+ }
+ // отдыхаем
+ Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
+ }
+ });
+ }
+
+ private async Task RunOrderInWork(ImplementerViewModel implementer)
+ {
+ if (_orderLogic == null || implementer == null)
+ {
+ return;
+ }
+ try
+ {
+ var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
+ {
+ ImplementerId = implementer.Id,
+ Status = OrderStatus.Выполняется
+ }));
+ if (runOrder == null)
+ {
+ return;
+ }
+
+ _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
+ // доделываем работу
+ Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
+ _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
+ _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = runOrder.Id
+ });
+ // отдыхаем
+ Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
+ }
+ // заказа может не быть, просто игнорируем ошибку
+ catch (InvalidOperationException ex)
+ {
+ _logger.LogWarning(ex, "Error try get work");
+ }
+ // а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error while do work");
+ throw;
+ }
+ }
+ }
+}
diff --git a/SushiBar/SushiBarClientApp/APIClient.cs b/SushiBar/SushiBarClientApp/APIClient.cs
index 216a26d..dd4b959 100644
--- a/SushiBar/SushiBarClientApp/APIClient.cs
+++ b/SushiBar/SushiBarClientApp/APIClient.cs
@@ -1,20 +1,21 @@
-using Newtonsoft.Json;
-using SushiBarContracts.ViewModels;
-using System.Net.Http.Headers;
+using System.Net.Http.Headers;
using System.Text;
+using SushiBarContracts.ViewModels;
+using Newtonsoft.Json;
+
namespace SushiBarClientApp
{
- public static class APIClient
+ 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"));
+ _client.DefaultRequestHeaders.Accept.Add(new
+ MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest(string requestUrl)
{
@@ -42,4 +43,5 @@ namespace SushiBarClientApp
}
}
}
-}
\ No newline at end of file
+
+}
diff --git a/SushiBar/SushiBarClientApp/Controllers/HomeController.cs b/SushiBar/SushiBarClientApp/Controllers/HomeController.cs
index 87d5378..05903f2 100644
--- a/SushiBar/SushiBarClientApp/Controllers/HomeController.cs
+++ b/SushiBar/SushiBarClientApp/Controllers/HomeController.cs
@@ -20,7 +20,8 @@ namespace SushiBarClientApp.Controllers
{
return Redirect("~/Home/Enter");
}
- return View(APIClient.GetRequest>($"api/main/getorders?clientId={APIClient.Client.Id}"));
+ return
+ View(APIClient.GetRequest>($"api/main/getorders?clientId={APIClient.Client.Id}"));
}
[HttpGet]
public IActionResult Privacy()
@@ -44,7 +45,7 @@ namespace SushiBarClientApp.Controllers
throw new Exception("Введите логин, пароль и ФИО");
}
APIClient.PostRequest("api/client/updatedata", new
- ClientBindingModel
+ ClientBindingModel
{
Id = APIClient.Client.Id,
ClientFIO = fio,
diff --git a/SushiBar/SushiBarClientApp/Program.cs b/SushiBar/SushiBarClientApp/Program.cs
index 8a8b56e..0f0c47d 100644
--- a/SushiBar/SushiBarClientApp/Program.cs
+++ b/SushiBar/SushiBarClientApp/Program.cs
@@ -8,7 +8,7 @@ APIClient.Connect(builder.Configuration);
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
- // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
+ // The default HSTS value is 30 days. You may want to change this for sushiion scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
diff --git a/SushiBar/SushiBarClientApp/Properties/launchSettings.json b/SushiBar/SushiBarClientApp/Properties/launchSettings.json
index 372c338..c04300b 100644
--- a/SushiBar/SushiBarClientApp/Properties/launchSettings.json
+++ b/SushiBar/SushiBarClientApp/Properties/launchSettings.json
@@ -1,22 +1,21 @@
-{
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:22876",
+ "sslPort": 44352
+ }
+ },
"profiles": {
- "http": {
+ "SushiBarClientApp": {
"commandName": "Project",
+ "dotnetRunMessages": true,
"launchBrowser": true,
+ "applicationUrl": "https://localhost:7121;http://localhost:5109",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
- },
- "dotnetRunMessages": true,
- "applicationUrl": "http://localhost:5222"
- },
- "https": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "dotnetRunMessages": true,
- "applicationUrl": "https://localhost:7084;http://localhost:5222"
+ }
},
"IIS Express": {
"commandName": "IISExpress",
@@ -25,14 +24,5 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
- },
- "$schema": "http://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:41478",
- "sslPort": 44302
- }
}
-}
\ No newline at end of file
+}
diff --git a/SushiBar/SushiBarClientApp/SushiBarClientApp.csproj b/SushiBar/SushiBarClientApp/SushiBarClientApp.csproj
index c1fd8c5..ea5528c 100644
--- a/SushiBar/SushiBarClientApp/SushiBarClientApp.csproj
+++ b/SushiBar/SushiBarClientApp/SushiBarClientApp.csproj
@@ -1,21 +1,17 @@
-
- net8.0
- enable
- enable
-
+
+ net8.0
+ enable
+ enable
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/SushiBar/SushiBarClientApp/Views/Home/Create.cshtml b/SushiBar/SushiBarClientApp/Views/Home/Create.cshtml
index e2d2305..3045f71 100644
--- a/SushiBar/SushiBarClientApp/Views/Home/Create.cshtml
+++ b/SushiBar/SushiBarClientApp/Views/Home/Create.cshtml
@@ -1,60 +1,50 @@
@{
- ViewData["Title"] = "Create";
+ ViewData["Title"] = "Create";
}
-
Создание заказа
+ Создание заказа
+
\ No newline at end of file
diff --git a/SushiBar/SushiBarClientApp/Views/Home/Enter.cshtml b/SushiBar/SushiBarClientApp/Views/Home/Enter.cshtml
index ac6dd7a..106d3d5 100644
--- a/SushiBar/SushiBarClientApp/Views/Home/Enter.cshtml
+++ b/SushiBar/SushiBarClientApp/Views/Home/Enter.cshtml
@@ -1,20 +1,21 @@
@{
- ViewData["Title"] = "Enter";
+ ViewData["Title"] = "Enter";
}
+
-
Вход в приложение
+ Вход в приложение
\ No newline at end of file
diff --git a/SushiBar/SushiBarClientApp/Views/Home/Index.cshtml b/SushiBar/SushiBarClientApp/Views/Home/Index.cshtml
index 5996441..843135f 100644
--- a/SushiBar/SushiBarClientApp/Views/Home/Index.cshtml
+++ b/SushiBar/SushiBarClientApp/Views/Home/Index.cshtml
@@ -1,75 +1,75 @@
@using SushiBarContracts.ViewModels
+
@model List
+
@{
- ViewData["Title"] = "Home Page";
+ ViewData["Title"] = "Home Page";
}
+
-
Заказы
+ Заказы
+
+
- @{
- if (Model == null)
- {
-
Авторизируйтесь
- return;
- }
-
- Создать заказ
-
-
-
-
-
- Номер
-
-
- Суши
-
-
- Дата создания
-
-
- Количество
-
-
- Сумма
-
-
- Статус
-
-
-
-
- @foreach (var item in Model)
- {
-
-
- @Html.DisplayFor(modelItem =>
- item.Id)
-
-
- @Html.DisplayFor(modelItem =>
- item.SushiName)
-
-
- @Html.DisplayFor(modelItem =>
- item.DateCreate)
-
-
- @Html.DisplayFor(modelItem =>
- item.Count)
-
-
- @Html.DisplayFor(modelItem =>
- item.Sum)
-
-
- @Html.DisplayFor(modelItem =>
- item.Status)
-
-
- }
-
-
- }
+ @{
+ if (Model == null)
+ {
+
Авторизируйтесь
+ return;
+ }
+
+
+ Создать заказ
+
+
+
+
+
+ Номер
+
+
+ Суши
+
+
+ Дата создания
+
+
+ Количество
+
+
+ Сумма
+
+
+ Статус
+
+
+
+
+ @foreach (var item in Model)
+ {
+
+
+ @Html.DisplayFor(modelItem => item.Id)
+
+
+ @Html.DisplayFor(modelItem => item.SushiName)
+
+
+ @Html.DisplayFor(modelItem => item.DateCreate)
+
+
+ @Html.DisplayFor(modelItem => item.Count)
+
+
+ @Html.DisplayFor(modelItem => item.Sum)
+
+
+ @Html.DisplayFor(modelItem => item.Status)
+
+
+ }
+
+
+ }
\ No newline at end of file
diff --git a/SushiBar/SushiBarClientApp/Views/Home/Privacy.cshtml b/SushiBar/SushiBarClientApp/Views/Home/Privacy.cshtml
index 7d00fb3..2871d24 100644
--- a/SushiBar/SushiBarClientApp/Views/Home/Privacy.cshtml
+++ b/SushiBar/SushiBarClientApp/Views/Home/Privacy.cshtml
@@ -1,37 +1,27 @@
@using SushiBarContracts.ViewModels
@model ClientViewModel
+
@{
- ViewData["Title"] = "Privacy Policy";
+ ViewData["Title"] = "Privacy Policy";
}
-
Личные данные
+ Личные данные
\ No newline at end of file
diff --git a/SushiBar/SushiBarClientApp/Views/Home/Register.cshtml b/SushiBar/SushiBarClientApp/Views/Home/Register.cshtml
index a2f84ee..398b516 100644
--- a/SushiBar/SushiBarClientApp/Views/Home/Register.cshtml
+++ b/SushiBar/SushiBarClientApp/Views/Home/Register.cshtml
@@ -1,27 +1,25 @@
@{
- ViewData["Title"] = "Register";
+ ViewData["Title"] = "Register";
}
+
-
Регистрация
+ Регистрация
\ No newline at end of file
diff --git a/SushiBar/SushiBarClientApp/Views/Shared/Error.cshtml b/SushiBar/SushiBarClientApp/Views/Shared/Error.cshtml
index a1e0478..4d96f6a 100644
--- a/SushiBar/SushiBarClientApp/Views/Shared/Error.cshtml
+++ b/SushiBar/SushiBarClientApp/Views/Shared/Error.cshtml
@@ -22,4 +22,4 @@
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
and restarting the app.
-
+
\ No newline at end of file
diff --git a/SushiBar/SushiBarClientApp/Views/Shared/_Layout.cshtml b/SushiBar/SushiBarClientApp/Views/Shared/_Layout.cshtml
index a6faae0..386e637 100644
--- a/SushiBar/SushiBarClientApp/Views/Shared/_Layout.cshtml
+++ b/SushiBar/SushiBarClientApp/Views/Shared/_Layout.cshtml
@@ -5,32 +5,33 @@
@ViewData["Title"] - SushiBarClientApp
-
+
+
-
-
-
Суши бар
-
+
+
Суши-Бар
+
-
+
@@ -42,12 +43,15 @@
@RenderBody()
+
+
+
- @RenderSection("Scripts", required: false)
+ @await RenderSectionAsync("Scripts", required: false)