public static IViewComponentResult LeftRightListBoxForAuth <TModel, TProperty>(this IHtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, IEnumerable <SelectListItem> selectList, Enumerations.Role requiredPrivilege, object htmlAttributes, out string controlId, string leftLabel = "Enabled", string rightLabel = "Disabled", string leftTitle = "Enable", string rightTitle = "Disable", bool allowSorting = true) { // If user has no privileges refuse access bool fullAccess = new UserSessionContext(htmlHelper.GetHttpContext()).UserHasAccess(requiredPrivilege); //Get the name of the control string name = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(htmlHelper.GetExpressionText(expression)); controlId = htmlHelper.GetFullHtmlFieldId(expression); if (String.IsNullOrEmpty(name)) { throw new ArgumentException("Value cannot be null or empty", "expression"); } IEnumerable <SelectListItem> rightList = (from s in selectList where s.Selected select s).ToList(); IEnumerable <SelectListItem> leftList = (from s in selectList where !s.Selected select s).ToList(); LeftRightListViewdata model = new LeftRightListViewdata { LeftList = leftList, RightList = rightList, LeftName = name + "__left", LeftId = controlId + "__left", RightName = name, RightId = controlId, HtmlAttributes = htmlAttributes, RequiredPrivilege = requiredPrivilege, AllowSorting = allowSorting, LeftLabel = leftLabel, RightLabel = rightLabel, LeftTitle = leftTitle, RightTitle = rightTitle }; return((new LeftRightListBoxComponent()).InvokeAsync("LeftRightList", new { list = model }).Result); //return htmlHelper.Action("LeftRightList", "Shared", new { list = model }); }
public IActionResult LeftRightList(LeftRightListViewdata list) { return(PartialView(list)); }