Merge branch 'main' of https://git.is.ulstu.ru/Serxionaft/Coursach
This commit is contained in:
commit
24ab0decab
@ -12,5 +12,6 @@ namespace Contracts.SearchModels
|
|||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public int? UserId { get; set; }
|
public int? UserId { get; set; }
|
||||||
public int? MachineId { get; set; }
|
public int? MachineId { get; set; }
|
||||||
|
public int? DetailId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,6 @@ namespace Contracts.SearchModels
|
|||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public int? UserId { get; set; }
|
public int? UserId { get; set; }
|
||||||
|
public int? DetailId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,14 @@ namespace DatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
|
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.UserId.HasValue)
|
if (!model.UserId.HasValue && !model.DetailId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new FactoryGoWorkDatabase();
|
using var context = new FactoryGoWorkDatabase();
|
||||||
|
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
|
||||||
return context.Products.Include(p => p.Details).ThenInclude(p => p.Detail).Where(x => x.UserId == model.Id).Select(x => x.GetViewModel).ToList();
|
return context.Products.Include(p => p.Details).ThenInclude(p => p.Detail).Where(x => x.UserId == model.Id).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +29,14 @@ namespace DatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<ProductionViewModel> GetFilteredList(ProductionSearchModel model)
|
public List<ProductionViewModel> GetFilteredList(ProductionSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.UserId.HasValue)
|
if (!model.UserId.HasValue && !model.DetailId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new FactoryGoWorkDatabase();
|
using var context = new FactoryGoWorkDatabase();
|
||||||
|
if (model.DetailId.HasValue)
|
||||||
|
return context.Productions.Include(x => x.Details).ThenInclude(x => x.Detail).Where(x => x.UserId == model.UserId).Where(x => x.Details.FirstOrDefault(y => y.DetailId == model.DetailId) != null).Include(x => x.User).Select(x => x.GetViewModel).ToList();
|
||||||
|
else
|
||||||
return context.Productions.Include(x => x.Details).ThenInclude(x => x.Detail).Where(x => x.UserId == model.UserId).Select(x => x.GetViewModel).ToList();
|
return context.Productions.Include(x => x.Details).ThenInclude(x => x.Detail).Where(x => x.UserId == model.UserId).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user