фиксы

This commit is contained in:
Леонид Малафеев 2024-05-28 10:37:29 +04:00
parent f73ace27d3
commit f9e191a08f
2 changed files with 25 additions and 23 deletions

View File

@ -24,25 +24,26 @@ namespace CarCenterDatabaseImplement.Implements
}
public List<StorekeeperViewModel> GetFilteredList(StorekeeperSearchModel model)
{
if (model == null)
if (!model.Id.HasValue)
{
return new();
}
if (model.Id.HasValue)
using var context = new CarCenterDatabase();
if (model.Id.HasValue)
{
var res = GetElement(model);
return res != null ? new() { res } : new();
}
return new();
return context.Storekeepers.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public StorekeeperViewModel? GetElement(StorekeeperSearchModel model)
{
using var context = new CarCenterDatabase();
if (model.Id.HasValue)
if (!model.Id.HasValue) { return null; }
if (model.Id.HasValue)
return context.Storekeepers
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;

View File

@ -24,19 +24,20 @@ namespace CarCenterDatabaseImplement.Implements
}
public List<WorkerViewModel> GetFilteredList(WorkerSearchModel model)
{
if (model == null)
{
return new();
}
if (model.Id.HasValue)
{
var res = GetElement(model);
return res != null ? new() { res } : new();
}
return new();
}
if (!model.Id.HasValue)
{
return new();
}
using var context = new CarCenterDatabase();
if (model.Id.HasValue)
{
return context.Workers.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public WorkerViewModel? GetElement(WorkerSearchModel model)
{