diff --git a/BeautySalon/CarCenterStorekeeperApp/StorekeeperData.cs b/BeautySalon/CarCenterStorekeeperApp/StorekeeperData.cs index e542c0b..757cc29 100644 --- a/BeautySalon/CarCenterStorekeeperApp/StorekeeperData.cs +++ b/BeautySalon/CarCenterStorekeeperApp/StorekeeperData.cs @@ -8,6 +8,7 @@ using CarCenterBusinessLogic.OfficePackage; using CarCenterDatabaseImplement.Models; using System.Linq; using CarCenterDataModels.Models; +using CarCenterBusinessLogic.BusinessLogics; namespace StorekeeperApp { @@ -131,7 +132,147 @@ namespace StorekeeperApp { return _orderLogic.ReadList(null); } + public List GetTimeReport(DateTime? startDate, DateTime? endDate, int UserId) + { + var services = _serviceLogic.ReadList(new() { DateFrom = startDate, DateTo = endDate, StorekeeperId = UserId }); + if (services == null) + return new(); + List serviceTimeReports = new List(); + foreach (var service in services) + { + var report = new ReportServiceViewModel(); + report.ServiceId = service.Id; + + List prs = new List(); + HashSet filteredOrders = new HashSet(); + + var procedures = _procedureLogic.ReadList(null);//get all procedures + var orders = _orderLogic.ReadList(null); //get all orders + + foreach (var p in procedures) + { + foreach(var s in p.ProcedureServices) + { + if(s.Value.Id == service.Id) + { + prs.Add(p); + break; + } + } + } + + foreach(var o in orders) + { + foreach (var p in prs) + { + foreach (var op in o.OrderProcedures) + { + if(op.Value.Id == p.Id) + { + filteredOrders.Add(o); break; + } + } + } + } + + HashSet laborcosts = new HashSet(); + var cosmetics = _cosmeticLogic.ReadList(null); + + foreach(var c in cosmetics) + { + foreach(var s in c.CosmeticServices) + { + if(s.Value.Id == service.Id) + { + laborcosts.Add(c.LaborCostID); + break; + } + } + } + + /*var orders = _orderLogic.ReadList(null); + + HashSet filteredOrders = new HashSet(); + List rmodels = new List(); + HashSet laborcosts = 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); + } + } + } + } + + 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.Orders = filteredOrders.Select(w => w.Id.ToString()).ToList(); + foreach (int l in laborcosts) + { + report.LaborCosts.Add(l.ToString()); + } + + serviceTimeReports.Add(report); + } + return serviceTimeReports; + } + + + /*public List GetTimeReport(DateTime? startDate, DateTime? endDate, int UserId) { var services = _serviceLogic.ReadList(new() { DateFrom = startDate, DateTo = endDate, StorekeeperId = UserId }); if (services == null) @@ -150,7 +291,7 @@ namespace StorekeeperApp serviceTimeReports.Add(report); } return serviceTimeReports; - } + }*/ public List? GetProcedureReports(List cosmetics) {