Esempio n. 1
0
        public static IHtmlContent RPCSDisplayProjectTitleView <TModel, TValue>(this IHtmlHelper <TModel> html,
                                                                                Project project,
                                                                                Expression <Func <TModel, TValue> > expression,
                                                                                string linkText, string action, object routeValues, OperationSet editRights, OperationSet displayRights)
        {
            var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>();

            if (appUserSvc.HasAccess(displayRights) && appUserSvc.IsMyProject(project) ||
                appUserSvc.HasAccess(editRights))
            {
                var          actionContext = _serviceProvider.GetService <IActionContextAccessor>().ActionContext;
                var          urlHelper     = (IUrlHelper) new UrlHelper(actionContext);
                IHtmlContent contents      = HtmlHelperDisplayExtensions.DisplayFor(html, expression);
                var          anchor        = new TagBuilder("a");
                anchor.InnerHtml.AppendHtml(contents);
                anchor.Attributes["href"]  = urlHelper.Action(action, "Project", routeValues);
                anchor.Attributes["title"] = string.IsNullOrEmpty(linkText) ? "" : linkText;

                return(new HtmlString(GetString(anchor)));
            }
            else
            {
                return(html.DisplayFor(expression));
            }
        }
Esempio n. 2
0
        public static IHtmlContent RPCSDisplayTitleViewActionWithPermissionFor <TModel, TValue>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, string linkText, string action, string controller, object routeValues, OperationSet displayRights, bool isBlank = false)
        {
            var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>();

            if (appUserSvc.HasAccess(displayRights))
            {
                var          urlHelper = _serviceProvider.GetRequiredService <IUrlHelper>();
                IHtmlContent contents  = HtmlHelperDisplayExtensions.DisplayFor(html, expression);
                var          anchor    = new TagBuilder("a");
                anchor.InnerHtml.Append(contents.ToString());
                anchor.Attributes["href"]  = urlHelper.Action(action, controller, routeValues);
                anchor.Attributes["title"] = string.IsNullOrEmpty(linkText) ? "" : linkText;
                if (isBlank)
                {
                    anchor.Attributes["target"] = "_blank";
                    anchor.Attributes["rel"]    = "noopener noreferrer";
                }

                return(new HtmlString(GetString(anchor)));
            }
            else
            {
                return(HtmlHelperDisplayExtensions.DisplayFor(html, expression));
            }
        }
Esempio n. 3
0
        public static IHtmlContent RPCSDisplayWithItemDetailsViewActionForEmployee <TModel, TValue1, TValue2>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, int employeeId, OperationSet displayRights,
                                                                                                              string itemController,
                                                                                                              object itemRouteValues,
                                                                                                              OperationSet viewItemDetailsRights)
        {
            var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>();

            bool hasAccess = appUserSvc.HasAccess(displayRights);

            if (displayRights.Contains(Operation.EmployeePersonalDataView) &&
                appUserSvc.HasAccess(Operation.EmployeeSubEmplPersonalDataView))
            {
                hasAccess = hasAccess || appUserSvc.IsDepartmentManagerForEmployee(employeeId);
            }
            if (displayRights.Contains(Operation.EmployeePersonalDataView) &&
                appUserSvc.GetEmployeeID() == employeeId)
            {
                hasAccess = true;
            }

            if (hasAccess)
            {
                IHtmlContent label    = HtmlHelperLabelExtensions.LabelFor(html, labelExpression, new { @class = "control-label col-md-4" });
                IHtmlContent contents = null;

                var value = ExpressionMetadataProvider.FromLambdaExpression(valueExpression, html.ViewData, html.MetadataProvider).Model;

                if (appUserSvc.HasAccess(viewItemDetailsRights) &&
                    value != null && String.IsNullOrEmpty(value.ToString()) == false)
                {
                    var    urlHelper = _serviceProvider.GetRequiredService <IUrlHelper>();
                    string linkText  = value.ToString();
                    var    anchor    = new TagBuilder("a");
                    anchor.InnerHtml.Append(string.IsNullOrEmpty(linkText) ? "No Name" : linkText);
                    anchor.Attributes["href"]   = urlHelper.Action("Details", itemController, itemRouteValues);
                    anchor.Attributes["target"] = "_blank";
                    contents = new HtmlString(GetString(anchor));
                }
                else
                {
                    contents = HtmlHelperDisplayExtensions.DisplayFor(html, valueExpression);
                }
                string result = String.Concat("<div class=\"row\">",
                                              GetString(label),
                                              "<div class=\"col-md-8\" style=\"padding:6px 12px\" >",
                                              GetString(contents),
                                              "</div>",
                                              "</div>");

                return(new HtmlString(result));
            }
            return(new HtmlString("")); // html.HiddenFor(expression);
        }
Esempio n. 4
0
        private static IHtmlContent GenerateLabel <TModel, TValue>(IHtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, IHtmlContent label)
        {
            IHtmlContent contents = HtmlHelperDisplayExtensions.DisplayFor(html, expression);
            string       result   = String.Concat("<div class=\"form-group\">",
                                                  GetString(label),
                                                  "<div class=\"col-md-8\"  style=\"padding:6px 12px\" >",
                                                  GetString(contents),
                                                  "</div>",
                                                  GetString(HtmlHelperInputExtensions.HiddenFor(html, expression)),
                                                  "</div>");

            return(new HtmlString(result));
        }
Esempio n. 5
0
        public static IHtmlContent RPCSDropDownList <TModel, TValue1, TValue2>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, string name,
                                                                               IEnumerable <SelectListItem> selectList, OperationSet editRights, OperationSet displayRights)
        {
            var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>();

            IHtmlContent label = HtmlHelperLabelExtensions.LabelFor(html, labelExpression, new { @class = "control-label col-md-4" });

            if (appUserSvc.HasAccess(editRights))
            {
                var contents = HtmlHelperSelectExtensions.DropDownList(html, name, selectList, new { @class = "form-control" });

                string result = String.Concat("<div class=\"form-group\">",
                                              GetString(label),
                                              "<div class=\"col-md-8\">",
                                              GetString(contents),
                                              "</div>",
                                              "</div>");
                return(new HtmlString(result));
            }
            if (appUserSvc.HasAccess(displayRights))
            {
                IHtmlContent contents = HtmlHelperDisplayExtensions.DisplayFor(html, valueExpression);
                string       result   = String.Concat("<div class=\"form-group\">",
                                                      GetString(label),
                                                      "<div class=\"col-md-8\">",
                                                      GetString(contents),
                                                      "</div>",
                                                      GetString(HtmlHelperInputExtensions.HiddenFor(html, valueExpression)),
                                                      GetString(HtmlHelperInputExtensions.HiddenFor(html, labelExpression)),
                                                      "</div>");
                return(new HtmlString(result));
            }
            string v = GetString(HtmlHelperInputExtensions.HiddenFor(html, valueExpression));
            string l = GetString(HtmlHelperInputExtensions.HiddenFor(html, labelExpression));

            return(new HtmlString(v + l));
        }
Esempio n. 6
0
        public static IHtmlContent RPCSAutocompleteDropDownList <TModel, TValue1, TValue2>(
            this IHtmlHelper <TModel> html,
            Expression <Func <TModel, TValue1> > labelExpression,
            Expression <Func <TModel, TValue2> > valueExpression,
            OperationSet editRights,
            OperationSet displayRights)
        {
            var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>();
            var label      = html.LabelFor(labelExpression, new { @class = "control-label col-md-4" });

            if (appUserSvc.HasAccess(editRights))
            {
                var    dropDown = GenerateDropDown(html, labelExpression);
                string result   = String.Concat("<div class=\"form-group\">",
                                                GetString(label),
                                                "<div class=\"col-md-8\">",
                                                GetString(dropDown),
                                                "</div>",
                                                "</div>");
                return(new HtmlString(result));
            }
            string l = GetString(html.HiddenFor(labelExpression));

            if (appUserSvc.HasAccess(displayRights))
            {
                var    contents = HtmlHelperDisplayExtensions.DisplayFor(html, valueExpression);
                string result   = String.Concat("<div class=\"form-group\">",
                                                GetString(label),
                                                "<div class=\"col-md-8\" style=\"padding:8px 12px\" >",
                                                GetString(contents),
                                                "</div>",
                                                "</div>");
                return(new HtmlString(result + l));
            }
            return(new HtmlString(l));
        }