diff --git a/CarShowroom/CarShowroomDataModels/SearchModel/CarSearch.cs b/CarShowroom/CarShowroomDataModels/SearchModel/CarSearch.cs index ae75407..5878e9e 100644 --- a/CarShowroom/CarShowroomDataModels/SearchModel/CarSearch.cs +++ b/CarShowroom/CarShowroomDataModels/SearchModel/CarSearch.cs @@ -9,5 +9,6 @@ namespace CarShowroomDataModels.SearchModel public class CarSearch { public int? Id; + public bool? IsSaled; } } diff --git a/CarShowroom/CarShowroomDatabaseStorage/Storages/CarStorage.cs b/CarShowroom/CarShowroomDatabaseStorage/Storages/CarStorage.cs index af7bf8c..d36ded9 100644 --- a/CarShowroom/CarShowroomDatabaseStorage/Storages/CarStorage.cs +++ b/CarShowroom/CarShowroomDatabaseStorage/Storages/CarStorage.cs @@ -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(); } diff --git a/CarShowroom/CarShowroomRestApi/Controllers/CarController.cs b/CarShowroom/CarShowroomRestApi/Controllers/CarController.cs index 4ea5656..cf9677d 100644 --- a/CarShowroom/CarShowroomRestApi/Controllers/CarController.cs +++ b/CarShowroom/CarShowroomRestApi/Controllers/CarController.cs @@ -24,16 +24,19 @@ namespace CarShowroomRestApi.Controllers { try { - return _logic.ReadList(null); + return _logic.ReadList(new CarSearch + { + IsSaled = false, + }); } catch (Exception ex) { _logger.LogError(ex, "Ошибка получения списка машин"); throw; } - } + } - [HttpGet] + [HttpGet] public CarView? GetCar(int CarId) { try