diff --git a/Course/Contracts/SearchModels/WorkshopSearchModel.cs b/Course/Contracts/SearchModels/WorkshopSearchModel.cs index 1f1d125..33ae887 100644 --- a/Course/Contracts/SearchModels/WorkshopSearchModel.cs +++ b/Course/Contracts/SearchModels/WorkshopSearchModel.cs @@ -5,5 +5,6 @@ public int? Id { get; set; } public string? Title { get; set; } public int? UserId { get; set; } + public int? DetailId { get; set; } } } diff --git a/Course/DatabaseImplement/Implements/WorkshopStorage.cs b/Course/DatabaseImplement/Implements/WorkshopStorage.cs index 573f155..a8743be 100644 --- a/Course/DatabaseImplement/Implements/WorkshopStorage.cs +++ b/Course/DatabaseImplement/Implements/WorkshopStorage.cs @@ -30,12 +30,15 @@ namespace DatabaseImplement.Implements public List GetFilteredList(WorkshopSearchModel model) { - if (!model.UserId.HasValue) + if (!model.UserId.HasValue && !model.DetailId.HasValue) { return new(); } using var context = new FactoryGoWorkDatabase(); - return context.Workshops.Include(x => x.Workers).ThenInclude(x => x.Worker).Where(x => x.UserId == model.UserId).Select(x => x.GetViewModel).ToList(); + if (model.DetailId.HasValue) + return context.Workshops.Include(x => x.Production).Where(x => x.Production.Details.FirstOrDefault(y => y.DetailId == model.DetailId) != null).Where(x => x.UserId == model.UserId).Select(x => x.GetViewModel).ToList(); + else + return context.Workshops.Include(x => x.Workers).ThenInclude(x => x.Worker).Where(x => x.UserId == model.UserId).Select(x => x.GetViewModel).ToList(); } public List GetFullList() diff --git a/Course/GuarantorAPP/Controllers/HomeController.cs b/Course/GuarantorAPP/Controllers/HomeController.cs index ed6b421..0870158 100644 --- a/Course/GuarantorAPP/Controllers/HomeController.cs +++ b/Course/GuarantorAPP/Controllers/HomeController.cs @@ -1,5 +1,4 @@ -using AspNetCore; -using Contracts.BusinessLogicsContracts; +using Contracts.BusinessLogicsContracts; using Contracts.ViewModels; using GuarantorAPP.Models; using Microsoft.AspNetCore.Mvc; diff --git a/Course/ImplementerApp/Controllers/HomeController.cs b/Course/ImplementerApp/Controllers/HomeController.cs index 6e00cd3..54266c8 100644 --- a/Course/ImplementerApp/Controllers/HomeController.cs +++ b/Course/ImplementerApp/Controllers/HomeController.cs @@ -161,13 +161,13 @@ namespace ImplementerApp.Controllers { DetailName = "Деталь А", Productions = new List { "Производство 1", "Производство 2" }, - Machines = new List { "Машина X", "Машина Y" } + Products = new List { "Машина X", "Машина Y" } }, new DetailTimeReport { DetailName = "Деталь B", Productions = new List { "Производство 3", "Производство 4" }, - Machines = new List { "Машина Z", "Машина W" } + Products = new List { "Машина Z", "Машина W" } } }; return View(detailTimeReports);