public ActionResult GetHeader() { var content = _contentRouteHelper.Content; var homePage = _contentLoader.Get <CommerceHomePage>(ContentReference.StartPage); return(PartialView("_Header", _headerViewModelFactory.CreateHeaderViewModel <CommerceHeaderViewModel>(content, homePage))); }
/// <summary> /// Mediator pattern is overkill in this instance, but here as an example to return response codes to a controller, and /// keep the controller dumb as a result /// </summary> /// <returns>A mediator response with the result of the view model instantiation</returns> public MediatorResponse <HeaderViewModel> RequestHeaderViewModel() { var HeaderItemDataSource = _HeaderService.GetHeaderItems(); if (HeaderItemDataSource == null) { return(_mediatorService.GetMediatorResponse <HeaderViewModel>(MediatorCodes.HeaderResponse.DataSourceError)); } var viewModel = _HeaderViewModelFactory.CreateHeaderViewModel(HeaderItemDataSource, _HeaderService.IsExperienceEditor); if (viewModel == null) { return(_mediatorService.GetMediatorResponse <HeaderViewModel>(MediatorCodes.HeaderResponse.ViewModelError)); } return(_mediatorService.GetMediatorResponse(MediatorCodes.HeaderResponse.Ok, viewModel)); }
public ActionResult GetHeader(CmsHomePage homePage) { var content = _contentRouteHelper.Content; return(PartialView("_Header", _headerViewModelFactory.CreateHeaderViewModel <HeaderViewModel>(content, homePage))); }
public async Task <IViewComponentResult> InvokeAsync(HomePage homePage) { var content = _contentRouteHelper.Content; return(View("_Header", _headerViewModelFactory.CreateHeaderViewModel(content, homePage))); }