Ejemplo n.º 1
0
 public virtual void CheckViewAccess(IAccessRole entity)
 {
     if (entity?.ViewRoleId != null)
     {
         if (!IsAuthorize((int)entity.ViewRoleId))
         {
             throw new UnauthorizedAccessException(LanguageManager.ToAsErrorMessage(ExceptionKey.InvalidGrant));
         }
     }
 }
Ejemplo n.º 2
0
 public virtual void CheckParentNodeModifyAccessForAddingChildNode(IAccessRole entity, int parentId)
 {
     try
     {
         SetAndCheckModifyAndAccessRole(entity, null, false);
     }
     catch (UnauthorizedAccessException)
     {
         throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.InvalidAccessForAddingChildToParenRecord, parentId.ToString()));
     }
 }
Ejemplo n.º 3
0
        public virtual void SetAndCheckModifyAndAccessRole(IAccessRole entity, dynamic newEntity, bool set = true)
        {
            if (entity == null)
            {
                return;
            }

            int?accessRoleId = newEntity == null ? null : newEntity.AccessRoleId;
            int?modifyRoleId = newEntity == null ? null : newEntity.ModifyRoleId;
            int?viewRoleId   = newEntity == null ? null : newEntity.ViewRoleId;

            if ((accessRoleId == null || modifyRoleId == null || viewRoleId == null) && set)
            {
                throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.RoleIsNull));
            }

            if (entity.ModifyRoleId != null)
            {
                if (!IsAuthorize((int)entity.ModifyRoleId))
                {
                    throw new UnauthorizedAccessException(LanguageManager.ToAsErrorMessage(ExceptionKey.InvalidGrant));
                }
            }
            if (entity.AccessRoleId != null)
            {
                if (!IsAuthorize((int)entity.AccessRoleId) || !set)
                {
                    return;
                }
                entity.ViewRoleId   = viewRoleId;
                entity.ModifyRoleId = modifyRoleId;
                entity.AccessRoleId = accessRoleId;
            }
            else
            {
                if (!set)
                {
                    return;
                }
                entity.ViewRoleId   = viewRoleId;
                entity.ModifyRoleId = modifyRoleId;
                entity.AccessRoleId = accessRoleId;
            }
        }
Ejemplo n.º 4
0
 public static void CheckViewAccess(IAccessRole entity)
 {
     Adapter.CheckViewAccess(entity);
 }
Ejemplo n.º 5
0
 public static void CheckParentNodeModifyAccessForAddingChildNode(IAccessRole entity, int parentId)
 {
     Adapter.CheckParentNodeModifyAccessForAddingChildNode(entity, parentId);
 }
Ejemplo n.º 6
0
 public static void SetAndCheckModifyAndAccessRole(IAccessRole entity, dynamic newEntity, bool set = true)
 {
     Adapter.SetAndCheckModifyAndAccessRole(entity, newEntity, set);
 }