Add and delete for assembly
This commit is contained in:
@@ -27,18 +27,29 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
}
|
||||
public List<AssemblyViewModel> GetFilteredList(AssemblySearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.AssemblyName))
|
||||
if (string.IsNullOrEmpty(model.AssemblyName) && model.ClientId == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerShopDatabase();
|
||||
return context.Assemblies
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.AssemblyName.Contains(model.AssemblyName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
if (model.ClientId != null)
|
||||
return context.Assemblies
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
else
|
||||
{
|
||||
return context.Assemblies
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.AssemblyName.Contains(model.AssemblyName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public AssemblyViewModel? GetElement(AssemblySearchModel model)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user