public virtual void CheckViewAccess(IAccessRole entity) { if (entity?.ViewRoleId != null) { if (!IsAuthorize((int)entity.ViewRoleId)) { throw new UnauthorizedAccessException(LanguageManager.ToAsErrorMessage(ExceptionKey.InvalidGrant)); } } }
public virtual void CheckParentNodeModifyAccessForAddingChildNode(IAccessRole entity, int parentId) { try { SetAndCheckModifyAndAccessRole(entity, null, false); } catch (UnauthorizedAccessException) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.InvalidAccessForAddingChildToParenRecord, parentId.ToString())); } }
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; } }
public static void CheckViewAccess(IAccessRole entity) { Adapter.CheckViewAccess(entity); }
public static void CheckParentNodeModifyAccessForAddingChildNode(IAccessRole entity, int parentId) { Adapter.CheckParentNodeModifyAccessForAddingChildNode(entity, parentId); }
public static void SetAndCheckModifyAndAccessRole(IAccessRole entity, dynamic newEntity, bool set = true) { Adapter.SetAndCheckModifyAndAccessRole(entity, newEntity, set); }