public ActionResult Index(IPortalUser user, PortletViewModel model) { var selectedViewModel = model.Items.SingleOrDefault(x => x.Url == user.CurrentOperation); if (selectedViewModel != null) { foreach(var vm in model.Items) { vm.Data = "none"; } selectedViewModel.Data = "Selected"; } return View(model); }
public static MvcHtmlString ActionFromPortlet(this HtmlHelper html, PortletViewModel model) { RouteValueDictionary routes = new RouteValueDictionary(); string[] urlValues = null; string[] urlKeys = null; string action = string.Empty; string controller = string.Empty; urlValues = model.Url.Split(new string[]{"/"}, StringSplitOptions.RemoveEmptyEntries); urlKeys = model.UrlFormat.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < urlKeys.Length; i++) { if (urlKeys[i].ToUpper() == "ACTION") { action = urlValues[i]; } else if (urlKeys[i].ToUpper() == "MODEL") { routes.Add(urlKeys[i], model); } else if (urlKeys[i].ToUpper() == "CONTROLLER") { controller = urlValues[i]; } else { routes.Add(urlKeys[i], urlValues[i]); } } if (string.IsNullOrEmpty(action)) { throw new Exception("No action has been defined for the portlet"); } else { MvcHtmlString route = html.Action(action,controller, routes); return route; } }
public ActionResult Index(PortletViewModel model) { return View(model); }