Example #1
0
        private static PermissionUpdateModel CreatePermission(
            IntranetMemberGroup group,
            Resource resource,
            PermissionActionEnum action,
            bool allowed = true, bool enabled = true)
        {
            var identity = PermissionSettingIdentity.Of(action, resource);
            var settings = PermissionSettingValues.Of(allowed, enabled);

            return(PermissionUpdateModel.Of(group, settings, identity));
        }
        public virtual GroupPermissionsViewModel Save(PermissionUpdateViewModel update)
        {
            var settingIdentity = PermissionSettingIdentity.Of(
                _actionTypeProvider[update.ActionId],
                _resourceTypeProvider[update.ResourceTypeId]);
            var settingValue = PermissionSettingValues.Of(update.Allowed, update.Enabled);
            var targetGroup  = _intranetMemberGroupProvider[update.IntranetMemberGroupId];

            var mappedUpdate = PermissionUpdateModel.Of(targetGroup, settingValue, settingIdentity);

            _permissionsService.Save(mappedUpdate);

            return(Get(update.IntranetMemberGroupId));
        }
        public ExecutionResult Execute()
        {
            var uiUserGroup = _intranetMemberGroupProvider.All.FirstOrDefault(g => g.Name.ToLowerInvariant() == "uiuser");

            if (uiUserGroup == null)
            {
                return(ExecutionResult.Success);
            }

            _permissionsService.Save(PermissionUpdateModel.Of(
                                         uiUserGroup,
                                         new PermissionSettingValues(false, false),
                                         new PermissionSettingIdentity(PermissionActionEnum.CanPin, PermissionResourceTypeEnum.Events)));

            _permissionsService.Save(PermissionUpdateModel.Of(
                                         uiUserGroup,
                                         new PermissionSettingValues(false, false),
                                         new PermissionSettingIdentity(PermissionActionEnum.CanPin, PermissionResourceTypeEnum.News)));

            return(ExecutionResult.Success);
        }