Ejemplo n.º 1
0
        public static string GetDescription(this PrivilegesPageType GenericEnum)
        {
            Type genericEnumType = GenericEnum.GetType();

            MemberInfo[] memberInfo = genericEnumType.GetMember(GenericEnum.ToString());
            if ((memberInfo.Length <= 0))
            {
                return(GenericEnum.ToString());
            }
            object[] attribs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
            return(attribs.Any() ? ((DescriptionAttribute)attribs.ElementAt(0)).Description : GenericEnum.ToString());
        }
Ejemplo n.º 2
0
        public BEUsersPrivilegesViewModel ValidateIBEUsersPrivilegesViewService(PrivilegesPageType pageTyp, string userId, bool isSuperAdmin, int pageId = -1, int approvalId = 0)
        {
            var bEUsersPrivilegesViewModel = new BEUsersPrivilegesViewModel();

            var userPrivileges = _bEUsersPrivilegesRepository.GetUserPrivileges(userId);


            if (pageTyp == PrivilegesPageType.DynamicPage && pageId != -1)
            {
                var pageRouteVersion = _pageRouteVersionRepository.GetById(pageId);
                if (pageRouteVersion != null && pageRouteVersion.PageRouteId != null)
                {
                    pageId = pageRouteVersion.PageRouteId ?? 0;
                }
                else
                {
                    pageId = -1;
                }
            }


            bEUsersPrivilegesViewModel.CanAdd = isSuperAdmin || ValidatePrivileges(new BEUsersPrivilegesRequirementModel(pageTyp, new PrivilegesActions[] { PrivilegesActions.CanAdd }, pageId), userPrivileges);

            bEUsersPrivilegesViewModel.CanEdit = isSuperAdmin || ValidatePrivileges(new BEUsersPrivilegesRequirementModel(pageTyp, new PrivilegesActions[] { PrivilegesActions.CanEdit }, pageId), userPrivileges);

            bEUsersPrivilegesViewModel.CanDelete = isSuperAdmin || ValidatePrivileges(new BEUsersPrivilegesRequirementModel(pageTyp, new PrivilegesActions[] { PrivilegesActions.CanDelete }, pageId), userPrivileges);

            bEUsersPrivilegesViewModel.CanApprove = isSuperAdmin || ValidatePrivileges(new BEUsersPrivilegesRequirementModel(pageTyp, new PrivilegesActions[] { PrivilegesActions.CanApprove }, pageId), userPrivileges);


            bEUsersPrivilegesViewModel.CanSubmit = isSuperAdmin || ValidatePrivileges(new BEUsersPrivilegesRequirementModel(pageTyp, new PrivilegesActions[] { PrivilegesActions.CanAdd, PrivilegesActions.CanEdit, PrivilegesActions.CanDelete }, pageId), userPrivileges);


            bEUsersPrivilegesViewModel.IsFromApprovalPage = approvalId > 0;

            return(bEUsersPrivilegesViewModel);
        }
Ejemplo n.º 3
0
 public BEUsersPrivilegesRequirementModel(PrivilegesPageType pageType, ICollection <PrivilegesActions> pageActions, int?pageId = null)
 {
     PageType    = pageType;
     PageActions = pageActions;
     PageId      = pageId;
 }
Ejemplo n.º 4
0
 public BEUsersPrivilegesRequirementAttribute(PrivilegesPageType pageType, PrivilegesActions[] pageActions, int pageId = -1) : base(typeof(BEUsersPrivilegesRequirementFilter))
 {
     Arguments = new object[] { new BEUsersPrivilegesRequirementModel(pageType, pageActions, pageId == -1 ? (int?)null : pageId) };
 }