SomeWorkshopReportImplementer

Work it harder, make it better
Do it faster, makes us stronger
More than ever, hour after hour
Work is never over
This commit is contained in:
Sergey Kozyrev 2024-04-30 22:06:53 +04:00
parent 24ab0decab
commit 1a18c24f37
4 changed files with 9 additions and 6 deletions

View File

@ -5,5 +5,6 @@
public int? Id { get; set; }
public string? Title { get; set; }
public int? UserId { get; set; }
public int? DetailId { get; set; }
}
}

View File

@ -30,12 +30,15 @@ namespace DatabaseImplement.Implements
public List<WorkshopViewModel> 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<WorkshopViewModel> GetFullList()

View File

@ -1,5 +1,4 @@
using AspNetCore;
using Contracts.BusinessLogicsContracts;
using Contracts.BusinessLogicsContracts;
using Contracts.ViewModels;
using GuarantorAPP.Models;
using Microsoft.AspNetCore.Mvc;

View File

@ -161,13 +161,13 @@ namespace ImplementerApp.Controllers
{
DetailName = "Деталь А",
Productions = new List<string> { "Производство 1", "Производство 2" },
Machines = new List<string> { "Машина X", "Машина Y" }
Products = new List<string> { "Машина X", "Машина Y" }
},
new DetailTimeReport
{
DetailName = "Деталь B",
Productions = new List<string> { "Производство 3", "Производство 4" },
Machines = new List<string> { "Машина Z", "Машина W" }
Products = new List<string> { "Машина Z", "Машина W" }
}
};
return View(detailTimeReports);