Advertisement
Guest User

Untitled

a guest
Oct 1st, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. namespace Cars.Web_New.Controllers
  2. {
  3. public class HomeController : BaseController
  4. {
  5. [OutputCache(Duration = 3000, Location = OutputCacheLocation.ServerAndClient)]
  6. public ActionResult Index()
  7. {
  8. var makes = this.Data.Marks
  9. .All()
  10. .Select(CarMakeViewModel.Create)
  11. .ToList();
  12.  
  13. var viewModel = new DropDownViewModel();
  14. viewModel.Makes = makes;
  15.  
  16. return View(viewModel);
  17. }
  18.  
  19. [OutputCache(Duration = 230, VaryByParam = "SelectedMakeId", Location = OutputCacheLocation.ServerAndClient)]
  20. public ActionResult SelectMake(int SelectedMakeId)
  21. {
  22. var models = this.Data.Marks
  23. .Find(SelectedMakeId)
  24. .CarModels.AsQueryable()
  25. .Select(CarModelViewModel.Create)
  26. .ToList();
  27.  
  28. var viewModel = new DropDownViewModel()
  29. {
  30. Models = models
  31. };
  32.  
  33. return this.PartialView("_ModelsDropDown", viewModel);
  34.  
  35. }
  36.  
  37. [OutputCache(Duration = 230, VaryByParam = "SelectedModelId")]
  38. public ActionResult SelectModel(int SelectedModelId)
  39. {
  40. var years = this.Data.Models
  41. .Find(SelectedModelId)
  42. .ModelYears
  43. .AsQueryable()
  44. .Select(CarYearViewModel.Create)
  45. .ToList();
  46.  
  47. var viewModel = new DropDownViewModel();
  48. viewModel.CarYears = years;
  49.  
  50. return this.PartialView("_YearsDropDown", viewModel);
  51. }
  52.  
  53.  
  54. [OutputCache(Duration = 230, VaryByParam = "SelectedCarYearId")]
  55. public ActionResult SelectYear(int SelectedCarYearId)
  56. {
  57. var year = this.Data.Years.Find(SelectedCarYearId);
  58.  
  59. return Json(new
  60. {
  61. Message = "Update"
  62. });
  63. }
  64.  
  65. public ActionResult Submit(DropDownViewModel model)
  66. {
  67. return Content("all submited :)");
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement