Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Cars.Web_New.Controllers
- {
- public class HomeController : BaseController
- {
- [OutputCache(Duration = 3000, Location = OutputCacheLocation.ServerAndClient)]
- public ActionResult Index()
- {
- var makes = this.Data.Marks
- .All()
- .Select(CarMakeViewModel.Create)
- .ToList();
- var viewModel = new DropDownViewModel();
- viewModel.Makes = makes;
- return View(viewModel);
- }
- [OutputCache(Duration = 230, VaryByParam = "SelectedMakeId", Location = OutputCacheLocation.ServerAndClient)]
- public ActionResult SelectMake(int SelectedMakeId)
- {
- var models = this.Data.Marks
- .Find(SelectedMakeId)
- .CarModels.AsQueryable()
- .Select(CarModelViewModel.Create)
- .ToList();
- var viewModel = new DropDownViewModel()
- {
- Models = models
- };
- return this.PartialView("_ModelsDropDown", viewModel);
- }
- [OutputCache(Duration = 230, VaryByParam = "SelectedModelId")]
- public ActionResult SelectModel(int SelectedModelId)
- {
- var years = this.Data.Models
- .Find(SelectedModelId)
- .ModelYears
- .AsQueryable()
- .Select(CarYearViewModel.Create)
- .ToList();
- var viewModel = new DropDownViewModel();
- viewModel.CarYears = years;
- return this.PartialView("_YearsDropDown", viewModel);
- }
- [OutputCache(Duration = 230, VaryByParam = "SelectedCarYearId")]
- public ActionResult SelectYear(int SelectedCarYearId)
- {
- var year = this.Data.Years.Find(SelectedCarYearId);
- return Json(new
- {
- Message = "Update"
- });
- }
- public ActionResult Submit(DropDownViewModel model)
- {
- return Content("all submited :)");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement