add unsaled cars filtration
This commit is contained in:
parent
3766e03974
commit
f4dd73833d
@ -9,5 +9,6 @@ namespace CarShowroomDataModels.SearchModel
|
||||
public class CarSearch
|
||||
{
|
||||
public int? Id;
|
||||
public bool? IsSaled;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,9 @@ namespace CarShowroomDatabaseStorage.Storages
|
||||
return context.Cars
|
||||
.Include(c => c.Model)
|
||||
.ThenInclude(m => m.Make)
|
||||
.Where(x => !model.Id.HasValue || x.Id == model.Id)
|
||||
.Where(x =>
|
||||
!model.Id.HasValue || x.Id == model.Id &&
|
||||
(!model.IsSaled.HasValue || x.IsSaled == model.IsSaled))
|
||||
.Select(x => x.GetView())
|
||||
.ToList();
|
||||
}
|
||||
|
@ -24,7 +24,10 @@ namespace CarShowroomRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
return _logic.ReadList(new CarSearch
|
||||
{
|
||||
IsSaled = false,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user