public async Task <IActionResult> GetFilteredCars([FromBody] CarsFilter filter, [FromQuery] int?index, [FromQuery] int?size) { var cars = await _carService.GetFilteredCars(filter, index, size); return(Ok(_mapper.Map <CarDto[]>(cars))); }
public static IQueryable <Car> ApplyFiltering(this IQueryable <Car> query, CarsFilter filter) { return(query .Where(FiltersConverter.GetModelsFunc(filter)) .Where(FiltersConverter.GetColorFunc(filter)) .Where(FiltersConverter.GetEngineVolumeFunc(filter)) .Where(FiltersConverter.GetPriceFunc(filter))); }
public static Expression <Func <Car, bool> > GetEngineVolumeFunc(CarsFilter filter) { if (filter.EngineVolumeId != null) { return(x => x.EngineVolumeId == filter.EngineVolumeId); } return(x => true); }
public static Expression <Func <Car, bool> > GetColorFunc(CarsFilter filter) { if (filter.ColorId != null) { return(x => x.ColorId == filter.ColorId); } return(x => true); }
public static Expression <Func <Car, bool> > GetModelsFunc(CarsFilter filter) { if (filter.ModelsId.Length != 0) { return(x => filter.ModelsId.Contains(x.ModelId)); } return(x => true); }
public async Task <int> GetCarsCount(CarsFilter filter) { return(filter.ModelsId != null ? await _carRepository .GetAll() .ApplyFiltering(filter) .CountAsync() : await _carRepository .GetAll() .CountAsync()); }
public async Task <IEnumerable <Car> > GetFilteredCars(CarsFilter filter, int?index, int?size) { return(await _carRepository .GetAll() .AsNoTracking() .ApplyFiltering(filter) .Include(x => x.Model) .ThenInclude(x => x.Vendor) .ApplyIncludes(x => x.Color, x => x.Model, x => x.EngineVolume, x => x.PriceHistories) .WithPagination(index, size) .ToListAsync()); }
public static Expression <Func <Car, bool> > GetPriceFunc(CarsFilter filter) { if (filter.Price.SelectedDate == null) { return(x => x.PriceHistories.OrderByDescending(i => i.Id).First().Price >= filter.Price.FromPrice && x.PriceHistories.OrderByDescending(i => i.Id).First().Price <= filter.Price.ToPrice); } return(x => x.PriceHistories.First(i => filter.Price.SelectedDate > i.Date).Price >= filter.Price.FromPrice && x.PriceHistories.First(i => filter.Price.SelectedDate > i.Date).Price <= filter.Price.ToPrice); }
public async Task <IActionResult> GetCarsCount([FromBody] CarsFilter filter) { return(Ok(await _carService.GetCarsCount(filter))); }
public List <CarsInfo.UsedCarsInfo> GetCarsFilterMobile(string carMakeID, string CarModalId, string Mileage, string Year, string Price, string Sort, string Orderby, string pageSize, string CurrentPage, string Zipcode, string AuthenticationID, string CustomerID) { CarsFilter objCarsFilter = new CarsFilter(); Filter objFilter = new Filter(); List <CarsInfo.UsedCarsInfo> objFilterdata = new List <CarsInfo.UsedCarsInfo>(); CarsInfo.UsedCarsInfo OBJ = new CarsInfo.UsedCarsInfo(); string sort = string.Empty; objCarsFilter.CurrentPage = CurrentPage; objCarsFilter.PageSize = pageSize; objCarsFilter.CarMakeid = carMakeID; objCarsFilter.CarModalId = CarModalId; objCarsFilter.Sort = Sort; objCarsFilter.Orderby = Orderby; objCarsFilter.ZipCode = Zipcode; objCarsFilter.Sort = sort; switch (Mileage) { case "Mileage1": objCarsFilter.Mileage1 = "Mileage1"; break; case "Mileage2": objCarsFilter.Mileage2 = "Mileage2"; break; case "Mileage3": objCarsFilter.Mileage3 = "Mileage3"; break; case "Mileage4": objCarsFilter.Mileage4 = "Mileage4"; break; case "Mileage5": objCarsFilter.Mileage5 = "Mileage5"; break; case "Mileage6": objCarsFilter.Mileage6 = "Mileage6"; break; case "Mileage7": objCarsFilter.Mileage7 = "Mileage7"; break; } switch (Year) { case "Year1a": objCarsFilter.Year1a = "Year1a"; break; case "Year1b": objCarsFilter.Year1b = "Year1b"; break; case "Year1": objCarsFilter.Year1 = "Year1"; break; case "Year2": objCarsFilter.Year2 = "Year2"; break; case "Year3": objCarsFilter.Year3 = "Year3"; break; case "Year4": objCarsFilter.Year4 = "Year4"; break; case "Year5": objCarsFilter.Year5 = "Year5"; break; case "Year6": objCarsFilter.Year6 = "Year6"; break; case "Year7": objCarsFilter.Year7 = "Year7"; break; } switch (Price) { case "Price1": objCarsFilter.Price1 = "Price1"; break; case "Price2": objCarsFilter.Price2 = "Price2"; break; case "Price3": objCarsFilter.Price3 = "Price3"; break; case "Price4": objCarsFilter.Price4 = "Price4"; break; case "Price5": objCarsFilter.Price5 = "Price5"; break; } ; FilterCars objFilterCars = new FilterCars(); MobileBL objMobileBL = new MobileBL(); if (CustomerID.Trim() != "") { string parameter = carMakeID + "," + CarModalId + "," + Mileage + "," + Year + "," + Price + "," + Sort + "," + Orderby + "," + Zipcode; DataSet dsSaveCustInfo = objMobileBL.SaveMobileCustomerInfo("GetCarsFilterMobile", CustomerID, AuthenticationID, parameter); } if (AuthenticationID == ConfigurationManager.AppSettings["AppleID"].ToString()) { objFilterdata = (List <CarsInfo.UsedCarsInfo>)objFilterCars.FilterSearchMobile(objCarsFilter); } return(objFilterdata); }
public CarView(ParentView parent_) { InitializeComponent(); parent = parent_; currentFilter = IdentityFilter.get(); }