Assembly components

This commit is contained in:
the
2023-05-17 13:52:06 +04:00
parent cfb0caf0f7
commit 91d0fccdb3
8 changed files with 141 additions and 18 deletions

View File

@@ -23,15 +23,25 @@ namespace ComputerShopDatabaseImplement.Implements
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel
model)
{
if (string.IsNullOrEmpty(model.ComponentName))
if (string.IsNullOrEmpty(model.ComponentName) && model.ClientId == null)
{
return new();
}
using var context = new ComputerShopDatabase();
return context.Components
.Where(x => x.ComponentName.Contains(model.ComponentName))
.Select(x => x.GetViewModel)
.ToList();
if (!string.IsNullOrEmpty(model.ComponentName))
{
return context.Components
.Where(x => x.ComponentName.Contains(model.ComponentName))
.Select(x => x.GetViewModel)
.ToList();
}
else
{
return context.Components
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
}
public ComponentViewModel? GetElement(ComponentSearchModel model)
{