From 25b20e8f809e2da001bca0bd16952d6fa3aac5a9 Mon Sep 17 00:00:00 2001 From: bocchanskyy Date: Wed, 25 Dec 2024 21:30:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90?= =?UTF-8?q?=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90?= =?UTF-8?q?=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90?= =?UTF-8?q?=D0=90....=20=D0=9F=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80?= =?UTF-8?q?=D1=8B=20=D0=B8=20=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D1=8B=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=D0=BE=D0=B2...=20?= =?UTF-8?q?=D0=A5=D0=BE=D1=82=D1=8F=20=D1=8D=D1=82=D0=BE=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=88=D0=B5=D0=BD=D0=BD=D0=BE=20=D0=BD=D0=B5?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BD=D0=BE....?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchModels/ProcedureSearchModel.cs | 2 +- .../Controllers/HomeController.cs | 120 +++++++++- .../StoreKeeperWebApp/StoreKeeperData.cs | 42 +++- .../Views/Home/CreateOrder.cshtml | 226 ++++++++++++++++++ .../Views/Home/CreateProcedure.cshtml | 181 ++++++++++++++ .../Views/Home/IndexOrder.cshtml | 54 +++++ .../Views/Home/IndexProcedure.cshtml | 76 ++++++ .../Views/Shared/_Layout.cshtml | 8 + 8 files changed, 700 insertions(+), 9 deletions(-) create mode 100644 BeautyStudio/StoreKeeperWebApp/Views/Home/CreateOrder.cshtml create mode 100644 BeautyStudio/StoreKeeperWebApp/Views/Home/CreateProcedure.cshtml create mode 100644 BeautyStudio/StoreKeeperWebApp/Views/Home/IndexOrder.cshtml create mode 100644 BeautyStudio/StoreKeeperWebApp/Views/Home/IndexProcedure.cshtml diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs index d9d5a94..49dd218 100644 --- a/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs +++ b/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs @@ -12,7 +12,7 @@ namespace BeautyStudioContracts.SearchModels public string ProcedureName { get; set; } = string.Empty; public string ProcedureDescription { get; set; } = string.Empty; public int? StoreKeeperId { get; set; } - public int? ComseticId { get; set; } + public int? CosmeticId { get; set; } } } diff --git a/BeautyStudio/StoreKeeperWebApp/Controllers/HomeController.cs b/BeautyStudio/StoreKeeperWebApp/Controllers/HomeController.cs index 89bc9d8..620e3e6 100644 --- a/BeautyStudio/StoreKeeperWebApp/Controllers/HomeController.cs +++ b/BeautyStudio/StoreKeeperWebApp/Controllers/HomeController.cs @@ -9,6 +9,8 @@ using BeautyStudioDataModels.Enums; using BeautyStudioDatabaseImplement.Models; using StoreKeeperWebApp.Models; using DocumentFormat.OpenXml.Wordprocessing; +using System.Globalization; +using DocumentFormat.OpenXml.Office2010.Excel; namespace StoreKeeperWebApp.Controllers { @@ -94,7 +96,7 @@ namespace StoreKeeperWebApp.Controllers [HttpGet] public IActionResult CreateService(int id) { - var procedures = _data.GetProcedures(); + var procedures = _data.GetProcedures(UserStoreKeeper.user.Id); ViewBag.AllProcedures = procedures; if (id != 0) { @@ -107,7 +109,7 @@ namespace StoreKeeperWebApp.Controllers [HttpPost] public IActionResult CreateService(ServiceBindingModel model, int[] procedureIds) { - var procedures = _data.GetProcedures(); + var procedures = _data.GetProcedures(UserStoreKeeper.user.Id); if (model.Id == 0) { model.DateCreate = DateTime.UtcNow; @@ -134,7 +136,119 @@ namespace StoreKeeperWebApp.Controllers return View(); } - [HttpGet] + [HttpGet] + public IActionResult IndexProcedure() + { + if (UserStoreKeeper.user != null) + { + var procedures = _data.GetProcedures(UserStoreKeeper.user.Id); + return View(procedures); + } + return RedirectToAction("IndexNonReg"); + } + [HttpPost] + public IActionResult IndexProcedure(int id) + { + _data.DeleteProcedures(id); + return RedirectToAction("IndexProcedure"); + } + [HttpGet] + public IActionResult CreateProcedure(int id) + { + var services = _data.GetServices(UserStoreKeeper.user.Id); + ViewBag.AllServices = services; + if (id != 0) + { + var value = _data.GetProcedure(id); + if (value != null) + return View(value); + } + return View(new ProcedureViewModel()); + } + [HttpPost] + public IActionResult CreateProcedure(ProcedureBindingModel model, int[] serviceIds) + { + var services = _data.GetServices(UserStoreKeeper.user.Id); + for (int i = 0; i < serviceIds.Length; i++) + { + var service = services!.FirstOrDefault(x => x.Id == serviceIds[i])!; + model.ProcedureServices.Add(i, service); + } + model.StoreKeeperId = UserStoreKeeper.user!.Id; + bool changed = false; + if (model.ProcedureServices.Count > 0) + { + if (model.Id != 0) + { + changed = _data.UpdateProcedures(model); + } + else + { + changed = _data.CreateProcedure(model); + } + } + if (changed) + return RedirectToAction("IndexProcedure"); + else + { + ViewBag.AllServices = services; + return View(model); + } + } + [HttpGet] + public IActionResult IndexOrder() + { + if (UserStoreKeeper.user != null) + { + var orders = _data.GetOrders(UserStoreKeeper.user.Id); + return View(orders); + } + return RedirectToAction("IndexNonReg"); + } + [HttpPost] + public IActionResult IndexOrder(int id) + { + _data.DeleteOrders(id); + return RedirectToAction("IndexOrder"); + } + [HttpGet] + public IActionResult CreateOrder(int id) + { + var cosmetics = _data.GetCosmetics(UserStoreKeeper.user.Id); + var procedures = _data.GetProcedures(UserStoreKeeper.user!.Id); + ViewBag.AllCosmetics = cosmetics; + ViewBag.AllProcedures = procedures; + if (id != 0) + { + var value = _data.GetOrder(id); + if (value != null) + return View(value); + } + return View(new OrderViewModel()); + } + [HttpPost] + public IActionResult CreateOrder(OrderBindingModel model, int[] cosmeticIds, int[] procedureIds, string Sum) + { + var cosmetics = _data.GetCosmetics(UserStoreKeeper.user.Id); + for (int i = 0; i < cosmeticIds.Length; i++) + { + var cosmetic = cosmetics!.FirstOrDefault(x => x.Id == cosmeticIds[i])!; + model.Cosmetics.Add(i, cosmetic); + } + var procedures = _data.GetProcedures(UserStoreKeeper.user!.Id); + for (int i = 0; i < procedureIds.Length; i++) + { + var procedure = procedures!.FirstOrDefault(x => x.Id == procedureIds[i])!; + model.OrderProcedures.Add(i, procedure); + } + model.StoreKeeperId = UserStoreKeeper.user!.Id; + model.Sum = double.Parse(Sum, CultureInfo.InvariantCulture); + ViewBag.AllCosmetics = cosmetics; + return View(model); + } + + + [HttpGet] public IActionResult IndexLaborCost() { if (UserStoreKeeper.user != null) diff --git a/BeautyStudio/StoreKeeperWebApp/StoreKeeperData.cs b/BeautyStudio/StoreKeeperWebApp/StoreKeeperData.cs index 2a62578..39f420c 100644 --- a/BeautyStudio/StoreKeeperWebApp/StoreKeeperData.cs +++ b/BeautyStudio/StoreKeeperWebApp/StoreKeeperData.cs @@ -9,6 +9,7 @@ using BeautyStudioDatabaseImplement.Models; using System.Linq; using BeautyStudioDataModels.Models; using BeautyStudioBusinessLogic.BusinessLogic; +using DocumentFormat.OpenXml.Spreadsheet; namespace StoreKeeperWebApp { @@ -124,15 +125,46 @@ namespace StoreKeeperWebApp { return _cosmeticLogic.Delete(new() { Id = cosmeticId }); } - public List? GetProcedures() + public ProcedureViewModel? GetProcedure(int id) + { + return _procedureLogic.ReadElement(new() { Id = id }); + } + public List? GetProcedures(int userId) { - return _procedureLogic.ReadList(null); + return _procedureLogic.ReadList(new ProcedureSearchModel() { StoreKeeperId = userId }); } - public List? GetOrders() + public bool CreateProcedure(ProcedureBindingModel model) { - return _orderLogic.ReadList(null); + return _procedureLogic.Create(model); + } + public bool UpdateProcedures(ProcedureBindingModel model) + { + return _procedureLogic.Update(model); + } + public bool DeleteProcedures(int procedureId) + { + return _procedureLogic.Delete(new() { Id = procedureId }); + } + public OrderViewModel? GetOrder(int id) + { + return _orderLogic.ReadElement(new() { Id = id }); + } + public List? GetOrders(int userId) + { + return _orderLogic.ReadList(new OrderSearchModel() { StoreKeeperId = userId }); + } + public bool CreateOrders(OrderBindingModel model) + { + return _orderLogic.Create(model); + } + public bool UpdateOrders(OrderBindingModel model) + { + return _orderLogic.Update(model); + } + public bool DeleteOrders(int orderId) + { + return _orderLogic.Delete(new() { Id = orderId }); } - public List GetTimeReport(DateTime? startDate, DateTime? endDate, int UserId) { var services = _serviceLogic.ReadList(new() { DateCreate = startDate, DateComplete = endDate, StoreKeeperId = UserId }); diff --git a/BeautyStudio/StoreKeeperWebApp/Views/Home/CreateOrder.cshtml b/BeautyStudio/StoreKeeperWebApp/Views/Home/CreateOrder.cshtml new file mode 100644 index 0000000..80f97dd --- /dev/null +++ b/BeautyStudio/StoreKeeperWebApp/Views/Home/CreateOrder.cshtml @@ -0,0 +1,226 @@ +@using BeautyStudioContracts.ViewModels; +@using BeautyStudioDataModels.Enums; + +@model OrderViewModel + +@{ + ViewData["Title"] = "CreateOrder"; + ViewBag.Procedures = Model.OrderProcedures; + ViewBag.Cosmetics = Model.Cosmetics; +} +
+

Создание заказа

+
+
+
+
Процедуры
+
+ + + + + + + + + + + + @foreach (var procedure in ViewBag.Procedures) + { + + + + + + + + } + +
ID процедуры Стоимость Удалить
+ @procedure.Value.Id + @procedure.Value.ProcedureCost
+
+ + +
+ + +
+
Косметика
+
+ + + + + + + + + + + + @foreach (var cosmetic in ViewBag.Cosmetics) + { + + + + + + + + } + +
ID косметики Стоимость Удалить
+ @cosmetic.Value.Id + @cosmetic.Value.CosmeticPrice
+
+ + +
+
+
Сумма:
+
+
+
+
+
+
+
+ + + + + diff --git a/BeautyStudio/StoreKeeperWebApp/Views/Home/CreateProcedure.cshtml b/BeautyStudio/StoreKeeperWebApp/Views/Home/CreateProcedure.cshtml new file mode 100644 index 0000000..023cac0 --- /dev/null +++ b/BeautyStudio/StoreKeeperWebApp/Views/Home/CreateProcedure.cshtml @@ -0,0 +1,181 @@ +@using BeautyStudioContracts.ViewModels; +@using BeautyStudioDataModels.Enums; + +@model ProcedureViewModel + +@{ + ViewData["Title"] = "CreateProcedure"; + ViewBag.Services = Model.ProcedureServices; +} +
+

Создание процедуры

+
+
+ @if (Model.Id != 0){ +

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

+ return; + } +
+
Название:
+
+ + +
+
+
+
Описание:
+
+ + +
+
+
+
Цена процедуры:
+
+ + +
+
+ +
+
Услуги
+
+ + + + + + + + + + + + @foreach (var service in ViewBag.Services) + { + + + + + + + + } + +
ID услуги Стоимость Удалить
+ @service.Value.Id + @service.Value.ServicePrice
+
+ + +
+
+
Сумма:
+
+
+
+
+
+
+
+ + + + + diff --git a/BeautyStudio/StoreKeeperWebApp/Views/Home/IndexOrder.cshtml b/BeautyStudio/StoreKeeperWebApp/Views/Home/IndexOrder.cshtml new file mode 100644 index 0000000..fdce34e --- /dev/null +++ b/BeautyStudio/StoreKeeperWebApp/Views/Home/IndexOrder.cshtml @@ -0,0 +1,54 @@ +@using BeautyStudioContracts.ViewModels; + +@model List + +@{ + ViewData["Title"] = "Orders"; +} + +
+

Заказы

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

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

+ return; + } +

+ Создать заказ +

+ + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + +
НомерДата оплатыСуммаИзменить заказУдалить заказ
@Html.DisplayFor(modelItem => item.Id)@Html.DisplayFor(modelItem => item.PaymentDate)@Html.DisplayFor(modelItem => item.Sum) + Изменить + +
+ + +
+
+ } +
\ No newline at end of file diff --git a/BeautyStudio/StoreKeeperWebApp/Views/Home/IndexProcedure.cshtml b/BeautyStudio/StoreKeeperWebApp/Views/Home/IndexProcedure.cshtml new file mode 100644 index 0000000..45e6ad0 --- /dev/null +++ b/BeautyStudio/StoreKeeperWebApp/Views/Home/IndexProcedure.cshtml @@ -0,0 +1,76 @@ +@using BeautyStudioContracts.ViewModels; + +@model List + +@{ + ViewData["Title"] = "Procedures"; +} + +
+

Процедуры

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

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

+ return; + } +

+ Создать процедуру +

+ + + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + + } + +
+ Номер + + Название + + Описание + + Цена + + Изменить процедуру + + Удалить процедуру +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.ProcedureName) + + @Html.DisplayFor(modelItem => item.ProcedureDescription) + + @Html.DisplayFor(modelItem => item.ProcedureCost) + + Изменить + +
+ + +
+
+ } +
\ No newline at end of file diff --git a/BeautyStudio/StoreKeeperWebApp/Views/Shared/_Layout.cshtml b/BeautyStudio/StoreKeeperWebApp/Views/Shared/_Layout.cshtml index 2eb40c6..93185ff 100644 --- a/BeautyStudio/StoreKeeperWebApp/Views/Shared/_Layout.cshtml +++ b/BeautyStudio/StoreKeeperWebApp/Views/Shared/_Layout.cshtml @@ -46,6 +46,14 @@ +