ProductFix
This commit is contained in:
parent
0c4da70df3
commit
23b5ce0cdd
@ -13,5 +13,6 @@ namespace Contracts.SearchModels
|
||||
public int? UserId { get; set; }
|
||||
public int? MachineId { get; set; }
|
||||
public int? WorkerId { get; set; }
|
||||
public int? DetailId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,15 @@ namespace DatabaseImplement.Implements
|
||||
|
||||
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
|
||||
{
|
||||
if (!model.UserId.HasValue && !model.WorkerId.HasValue)
|
||||
if (!model.UserId.HasValue && !model.WorkerId.HasValue && !model.DetailId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new FactoryGoWorkDatabase();
|
||||
if (model.WorkerId.HasValue)
|
||||
return context.Products.Include(p => p.Details).ThenInclude(p => p.Detail).Where(x => x.UserId == model.Id).Where(x => x.Details.FirstOrDefault(y => y.DetailId == model.WorkerId) != null).Select(x => x.GetViewModel).ToList();
|
||||
if (model.DetailId.HasValue)
|
||||
return context.Products.Include(p => p.Details).ThenInclude(p => p.Detail).Where(x => x.UserId == model.Id).Where(x => x.Details.FirstOrDefault(y => y.DetailId == model.DetailId) != null).Select(x => x.GetViewModel).ToList();
|
||||
else if (model.WorkerId.HasValue)
|
||||
return context.Products.Where(p => p.MachineId.HasValue).Include(p => p.Machine).ThenInclude(p => p.Workers).Where(x => x.Machine.Workers.FirstOrDefault(y => y.WorkerId == model.WorkerId) != null).Select(x => x.GetViewModel).ToList();
|
||||
else
|
||||
return context.Products.Include(p => p.Details).ThenInclude(p => p.Detail).Where(x => x.UserId == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user