public ActionResult Submit(DropDownViewModel model) { var carsQuery = this.cache.AllCarsWithotModel; if (model.SelectedMakeId != 0) { carsQuery = carsQuery.Where(c => c.CarMakeId == model.SelectedMakeId); } if (model.SelectedModelId != 0) { carsQuery = carsQuery.Where(c => c.CarModelId == model.SelectedModelId); } if (model.SelectedCarYearId != 0) { carsQuery = carsQuery.Where(c => c.CarMakeId == model.SelectedModelId); } var cars = carsQuery.AsQueryable() .Project() .To<CarViewModel>() .ToList(); return this.PartialView("_CarsBox", cars); }
public ActionResult Index() { var makes = this.cache.CarModels; var carsCount = this.cache.AllCars.Count; var viewModel = new DropDownViewModel(); viewModel.Makes = makes; viewModel.AllCarsInDatabaseCount = carsCount; return this.View(viewModel); }
public ActionResult SelectModel(int selectedModelId) { var years = this.Data.Models .Find(selectedModelId) .ModelYears .AsQueryable() .Project() .To<CarYearViewModel>() .ToList(); var viewModel = new DropDownViewModel(); viewModel.CarYears = years; return this.PartialView("_YearsDropDown", viewModel); }
public ActionResult SelectMake(int selectedMakeId) { var models = this.Data.Marks .Find(selectedMakeId) .CarModels .AsQueryable() .Project() .To<CarModelViewModel>() .ToList(); var viewModel = new DropDownViewModel() { Models = models }; return this.PartialView("_ModelsDropDown", viewModel); }