add unsaled cars filtration
This commit is contained in:
parent
3766e03974
commit
f4dd73833d
@ -9,5 +9,6 @@ namespace CarShowroomDataModels.SearchModel
|
|||||||
public class CarSearch
|
public class CarSearch
|
||||||
{
|
{
|
||||||
public int? Id;
|
public int? Id;
|
||||||
|
public bool? IsSaled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,9 @@ namespace CarShowroomDatabaseStorage.Storages
|
|||||||
return context.Cars
|
return context.Cars
|
||||||
.Include(c => c.Model)
|
.Include(c => c.Model)
|
||||||
.ThenInclude(m => m.Make)
|
.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())
|
.Select(x => x.GetView())
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -24,16 +24,19 @@ namespace CarShowroomRestApi.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _logic.ReadList(null);
|
return _logic.ReadList(new CarSearch
|
||||||
|
{
|
||||||
|
IsSaled = false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка получения списка машин");
|
_logger.LogError(ex, "Ошибка получения списка машин");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public CarView? GetCar(int CarId)
|
public CarView? GetCar(int CarId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user