Add and delete for assembly

This commit is contained in:
the
2023-05-17 12:19:00 +04:00
parent 904981a408
commit cfb0caf0f7
10 changed files with 180 additions and 157 deletions

View File

@@ -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)
{