Custom Model In Index ActionMethod - Returing it parsed as IMasterModel
Hi,
I have encountered a problem where I have a controller and have Index ActionMethod, like the following:
public override ActionResult Index(RenderModel model)
{
//var url = this.Umbraco.UmbracoContext.RoutingContext.UrlProvider.
var umbraco = _umbracoControllerWrapperService.GetUmbracoHelperForUmbracoController(this);
var redirectUrl =
_getBoatSearchRedirectUrlIfCategoriesOrActivitiesInQuerystringService
.GetBoatSearchResultsFriendlyRedirectUrlFromCurrentRequest(umbraco);
if (string.IsNullOrWhiteSpace(redirectUrl))
{
var boatSearchParameters =
_pageService.GetHttpContextItemAndIfEmptyLoadItAndStoreIt(
ConstantValues.BoatSearchParameters_HttpContext_Item_Key,
getBoatSearchParametersForCurrentPageUrl);
var boatResults = _boatSearcherService.Search(umbraco, boatSearchParameters);
var boats = new BoatSearchResultsModel(model.Content);
boats.CategoryOrActivity =
_boatSearchResultsLoadCategoryOrActivityFromSearchParametersService
.LoadCategoryOrActivityFromSearchParametersIfOnlyOneSet(umbraco,
boatSearchParameters);
boats.BoatSearchResults = boatResults;
boats.SearchParameters = boatSearchParameters;
boats.SeoTexts =
_generateSeoTextsForBoatSearchParametersOrPageService.GenerateSeoTextsForBoatSearchParametersOrPage(
umbraco,
boatSearchParameters,
boats.CategoryOrActivity);
var newRm = new RenderModel(boats);
return _umbracoControllerWrapperService.CallBaseIndexMethod(this, newRm);
}
else
{
//Redirect ot it
return RedirectPermanent(redirectUrl);
}
Seeing the above code, how can I return the model to be parsed as well to IMasterModel, since my master page is accepting IMasterModel and I can set the View to accept: @inherits Umbraco.Web.Mvc.UmbracoViewPage<>
Couldn't you use a partial class that holds your "extended" view data.
and populate the extra view data from the hijacked controller just as the home page or Newsoverview page does.
Custom Model In Index ActionMethod - Returing it parsed as IMasterModel
Hi,
I have encountered a problem where I have a controller and have Index ActionMethod, like the following:
Seeing the above code, how can I return the model to be parsed as well to IMasterModel, since my master page is accepting IMasterModel and I can set the View to accept: @inherits Umbraco.Web.Mvc.UmbracoViewPage<>
Any idea please?
Kind Regards
Hi,
Have U looked at the best practises project on github here: https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises
Couldn't you use a partial class that holds your "extended" view data. and populate the extra view data from the hijacked controller just as the home page or Newsoverview page does.
// Regards, Robert
is working on a reply...