/// <summary>
 /// Filter to apply the mapping between the Core.Survey business object
 /// and the Model.TopTenSurveysViewModel.  It uses Automapper to perform
 /// the mapping.  The configuration of Automapper is in the Mapping folder
 /// </summary>
 /// <param name="filterContext">The filterContext returned by the Action method, containing the Controller viewData.</param>
 /// <remarks>
 /// We override the OnActionExecuted so that the mapping is done AFTER the
 /// action method has executed.  The action method returns the Domain,Order
 /// object and this filter passes the mapped Model.OrderDetailViewModel 
 /// to the view prior to it being rendered.
 /// </remarks>
 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     //  create an instance of the viewmodel class and map the incomming data to it
     HomeLChooseViewModel viewModel = new HomeLChooseViewModel();
     //  populate the viewModel
     viewModel.Categories = new SelectList(_categoryRepository.GetAll(), "CategoryId", "Description");
     //replace the viewData in the filterContext.
     filterContext.Controller.ViewData.Model = viewModel;
 }
 public ActionResult Choose()
 {
     ViewBag.Message = "Select a category to display the list of available surveys";
     ViewBag.Title = "Available Surveys";
     //  create an instance of the viewmodel class and map the incomming data to it
     HomeLChooseViewModel viewModel = new HomeLChooseViewModel();
     //  populate the viewModel wth the categories
     viewModel.Categories = new SelectList(_categoryRepository.GetAll(), "CategoryId", "Description");
     //  Now pass the viewModel to the view, avoids sending the null to the view, which avoids the
     //  null reference exceptions being suppressed automatically and improves performance.
     return View(viewModel);
 }