diff --git a/BeautySalon/CarCenterStorekeeperApp/StorekeeperData.cs b/BeautySalon/CarCenterStorekeeperApp/StorekeeperData.cs index 76e3c9a..e542c0b 100644 --- a/BeautySalon/CarCenterStorekeeperApp/StorekeeperData.cs +++ b/BeautySalon/CarCenterStorekeeperApp/StorekeeperData.cs @@ -162,7 +162,7 @@ namespace StorekeeperApp report.CosmeticName = cosmetic!.CosmeticName; var procedures = _procedureLogic.ReadList(null); - List filteredProcedures = new List(); + HashSet filteredProcedures = new HashSet(); if (cosmetic.CosmeticServices != null && procedures != null) { diff --git a/BeautySalon/CarCenterWorkerApp/Controllers/HomeController.cs b/BeautySalon/CarCenterWorkerApp/Controllers/HomeController.cs index 3f1acfe..555cd72 100644 --- a/BeautySalon/CarCenterWorkerApp/Controllers/HomeController.cs +++ b/BeautySalon/CarCenterWorkerApp/Controllers/HomeController.cs @@ -413,7 +413,7 @@ namespace CarCenterWorkerApp.Controllers return RedirectToAction("ProcedureCosmeticChoose"); } [HttpGet] - public IActionResult ProcedureCosmeticReport() + public IActionResult ProcedureCosmeticsReport() { var value = HttpContext.Session.GetString("Procedures"); if (value != null) diff --git a/BeautySalon/CarCenterWorkerApp/Views/Home/IndexOrder.cshtml b/BeautySalon/CarCenterWorkerApp/Views/Home/IndexOrder.cshtml index 6eeadfe..7cdf48f 100644 --- a/BeautySalon/CarCenterWorkerApp/Views/Home/IndexOrder.cshtml +++ b/BeautySalon/CarCenterWorkerApp/Views/Home/IndexOrder.cshtml @@ -3,86 +3,63 @@ @model List @{ - ViewData["Title"] = "Orders"; + ViewData["Title"] = "Orders"; }
-

Заказы

+

Заказы

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

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

- return; - } -

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

- - - - - - - - - - - - - - - @foreach (var item in Model) - { - - - - - - - - - - - } - -
- Номер - - Тип оплаты - - Статус оплаты - - Дата оплаты - - Имя работника - - Сумма - - Изменить заказ - - Удалить заказ -
- @Html.DisplayFor(modelItem => item.Id) - - @Html.DisplayFor(modelItem => item.PaymentType) - - @Html.DisplayFor(modelItem => item.PaymentStatus) - - @Html.DisplayFor(modelItem => item.PaymentDate) - - @Html.DisplayFor(modelItem => item.WorkerName) - - @Html.DisplayFor(modelItem => item.Sum) - - Изменить - -
- - -
-
- } + @{ + if (Model == null) + { +

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

+ return; + } +

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

+ + + + + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + + + + } + +
НомерТип оплатыСтатус оплатыДата оплатыИмя работникаСуммаИзменить заказУдалить заказ
@Html.DisplayFor(modelItem => item.Id)@Html.DisplayFor(modelItem => item.PaymentType)@Html.DisplayFor(modelItem => item.PaymentStatus) + @if (item.PaymentStatus == CarCenterDataModels.Enums.PaymentStatus.Оплачено) + { + @Html.DisplayFor(modelItem => item.PaymentDate) + } + @Html.DisplayFor(modelItem => item.WorkerName)@Html.DisplayFor(modelItem => item.Sum) + Изменить + +
+ + +
+
+ }
\ No newline at end of file diff --git a/BeautySalon/CarCenterWorkerApp/WorkerData.cs b/BeautySalon/CarCenterWorkerApp/WorkerData.cs index 4e763be..549e0bf 100644 --- a/BeautySalon/CarCenterWorkerApp/WorkerData.cs +++ b/BeautySalon/CarCenterWorkerApp/WorkerData.cs @@ -9,25 +9,26 @@ using DocumentFormat.OpenXml.Spreadsheet; using CarCenterDataModels.Models; using CarCenterBusinessLogic.MailWorker; using CarCenterBusinessLogic.OfficePackage; +using CarCenterDatabaseImplement.Models; namespace WorkerApp { - public class WorkerData - { - private readonly ILogger _logger; - private readonly IWorkerLogic _storekeeperLogic; - private readonly IProcedureLogic _procedureLogic; - private readonly IRatingLogic _ratingLogic; - private readonly IOrderLogic _orderLogic; - private readonly ICosmeticLogic _cosmeticLogic; + public class WorkerData + { + private readonly ILogger _logger; + private readonly IWorkerLogic _storekeeperLogic; + private readonly IProcedureLogic _procedureLogic; + private readonly IRatingLogic _ratingLogic; + private readonly IOrderLogic _orderLogic; + private readonly ICosmeticLogic _cosmeticLogic; private readonly IServiceLogic _serviceLogic; private readonly AbstractSaveToExcelWorker _excel; private readonly AbstractSaveToWordWorker _word; private readonly AbstractSaveToPdfWorker _pdf; private readonly AbstractMailWorker _mail; - public WorkerData(ILogger logger, IWorkerLogic storekeeperLogic, IProcedureLogic procedureLogic, - IRatingLogic ratingLogic, IOrderLogic orderLogic, IServiceLogic serviceLogic, ICosmeticLogic cosmeticLogic, + public WorkerData(ILogger logger, IWorkerLogic storekeeperLogic, IProcedureLogic procedureLogic, + IRatingLogic ratingLogic, IOrderLogic orderLogic, IServiceLogic serviceLogic, ICosmeticLogic cosmeticLogic, AbstractSaveToExcelWorker excel, AbstractSaveToWordWorker word, AbstractMailWorker mail, @@ -47,82 +48,82 @@ namespace WorkerApp } public WorkerViewModel? Login(string email, string password) - { - return _storekeeperLogic.ReadElement(new() - { - Email = email, - Password = password - }); - } - public bool Register(WorkerBindingModel model) - { - return _storekeeperLogic.Create(model); - } - public bool UpdateUser(WorkerBindingModel model) - { - return _storekeeperLogic.Update(model); - } + { + return _storekeeperLogic.ReadElement(new() + { + Email = email, + Password = password + }); + } + public bool Register(WorkerBindingModel model) + { + return _storekeeperLogic.Create(model); + } + public bool UpdateUser(WorkerBindingModel model) + { + return _storekeeperLogic.Update(model); + } - public List? GetProcedures(int userId) - { - return _procedureLogic.ReadList(new ProcedureSearchModel() { WorkerId = userId }); - } - public bool DeleteProcedure(int procedureId) - { - return _procedureLogic.Delete(new() { Id = procedureId }); - } - public bool CreateProcedure(ProcedureBindingModel model) - { - return _procedureLogic.Create(model); - } - public bool UpdateProcedure(ProcedureBindingModel model) - { - return _procedureLogic.Update(model); - } - public ProcedureViewModel? GetProcedure(int id) - { - return _procedureLogic.ReadElement(new() { Id = id }); - } - public List? GetRatings(int userId) - { - return _ratingLogic.ReadList(new RatingSearchModel() { WorkerId = userId }); - } - public bool DeleteRating(int procedureId) - { - return _ratingLogic.Delete(new() { Id = procedureId }); - } - public bool CreateRating(RatingBindingModel model) - { - return _ratingLogic.Create(model); - } - public bool UpdateRating(RatingBindingModel model) - { - return _ratingLogic.Update(model); - } - public RatingViewModel? GetRating(int id) - { - return _ratingLogic.ReadElement(new() { Id = id }); - } - public List? GetOrders(int userId) - { - return _orderLogic.ReadList(new() { WorkerId = userId }); - } - public OrderViewModel? GetOrder(int id) - { - return _orderLogic.ReadElement(new() { Id = id }); - } - public bool CreateOrder(OrderBindingModel model) - { - return _orderLogic.Create(model); - } - public bool UpdateOrder(OrderBindingModel model) - { - return _orderLogic.Update(model); - } - public bool DeleteOrder(int orderId) - { - return _orderLogic.Delete(new() { Id = orderId }); - } + public List? GetProcedures(int userId) + { + return _procedureLogic.ReadList(new ProcedureSearchModel() { WorkerId = userId }); + } + public bool DeleteProcedure(int procedureId) + { + return _procedureLogic.Delete(new() { Id = procedureId }); + } + public bool CreateProcedure(ProcedureBindingModel model) + { + return _procedureLogic.Create(model); + } + public bool UpdateProcedure(ProcedureBindingModel model) + { + return _procedureLogic.Update(model); + } + public ProcedureViewModel? GetProcedure(int id) + { + return _procedureLogic.ReadElement(new() { Id = id }); + } + public List? GetRatings(int userId) + { + return _ratingLogic.ReadList(new RatingSearchModel() { WorkerId = userId }); + } + public bool DeleteRating(int procedureId) + { + return _ratingLogic.Delete(new() { Id = procedureId }); + } + public bool CreateRating(RatingBindingModel model) + { + return _ratingLogic.Create(model); + } + public bool UpdateRating(RatingBindingModel model) + { + return _ratingLogic.Update(model); + } + public RatingViewModel? GetRating(int id) + { + return _ratingLogic.ReadElement(new() { Id = id }); + } + public List? GetOrders(int userId) + { + return _orderLogic.ReadList(new() { WorkerId = userId }); + } + public OrderViewModel? GetOrder(int id) + { + return _orderLogic.ReadElement(new() { Id = id }); + } + public bool CreateOrder(OrderBindingModel model) + { + return _orderLogic.Create(model); + } + public bool UpdateOrder(OrderBindingModel model) + { + return _orderLogic.Update(model); + } + public bool DeleteOrder(int orderId) + { + return _orderLogic.Delete(new() { Id = orderId }); + } public List? GetServices() { return _serviceLogic.ReadList(null); @@ -143,12 +144,105 @@ namespace WorkerApp { var report = new ReportOrderViewModel(); report.OrderId = order.Id; - var ratings = _ratingLogic.ReadList(new() { OrderId = order.Id, WorkerId = UserId }); - if (ratings != null) - report.Ratings = ratings.Select(p => p.Id.ToString()).ToList(); - var services = _serviceLogic.ReadList(new() { OrderId = order.Id, StorekeeperId = UserId }); - if (services != null) - report.Services = services.Select(p => p.Id.ToString()).ToList(); + + + var services = _serviceLogic.ReadList(null); + + HashSet filteredServices = new HashSet(); + List rmodels = new List(); + HashSet ratings = new HashSet(); + + if (order.OrderProcedures != null && services != null) + { + var proceduresO = new HashSet(order.OrderProcedures.Values);//получаем процедуры, + //фигурирующие в заказе + + var procedures = _procedureLogic.ReadList(null);//все процедуры в формате ViewMode + + + foreach (var procedure in proceduresO) + { + foreach (var pr in procedures) + { + if (procedure.Id == pr.Id) + { + foreach (var point in pr.Ratings) + { + rmodels.Add(point.Value); + } + } + } + } + + List servs = new List();//заполняем услугами из процедур + //(тут еще пока IServiceMOdel и повторы) + + foreach (var p in procedures) + { + foreach (var pc in proceduresO) + { + if (p.Id == pc.Id) + { + foreach (var s in p.ProcedureServices) + { + servs.Add(s.Value); + } + } + } + } + + foreach(var sv in servs) + { + foreach(var s in services) + { + if(sv.Id == s.Id) + { + filteredServices.Add(s); + } + } + } + } + + + + /*foreach (var service in services) + { + if (service.ServiceProcedures != null) + { + var proceduresS = new HashSet(service.ServiceProcedures.Values); + foreach (IProcedureModel proc in proceduresS) + { + foreach (IProcedureModel p in proceduresO) + { + if (p.Id == proc.Id) + { + filteredServices.Add(service); + break; + } + } + } + } + } + }*/ + + var rats = _ratingLogic.ReadList(null); + foreach (var rats1 in rats) + { + foreach (var r1 in rmodels) + { + if (rats1.Id == r1.Id) + { + ratings.Add(rats1.Points); + } + } + } + + report.Services = filteredServices.Select(w => w.ServiceName).ToList(); + foreach (double rat in ratings) + { + report.Ratings.Add(rat.ToString()); + } + orderTimeReports.Add(report); } return orderTimeReports; @@ -164,7 +258,7 @@ namespace WorkerApp report.ProcedureName = procedure!.ProcedureName; var cosmetics = _cosmeticLogic.ReadList(null); - List filteredCosmetics = new List(); + HashSet filteredCosmetics = new HashSet(); if (procedure.ProcedureServices != null && cosmetics != null) {