public ExecutionResult Execute() { _logger.Info <SetupDefaultMemberGroupsPermissionsStep>("SetupDefaultMemberGroupsPermissionsStep is running"); var existedPermissions = _permissionsService.GetAll(); if (existedPermissions.Any()) { _logger.Info <SetupDefaultMemberGroupsPermissionsStep>("Database contains some permissions. Step has been skipped"); return(ExecutionResult.Success); } var memberGroups = _intranetMemberGroupService.GetAll(); var permissions = memberGroups.Select(group => { switch (group.Name) { case UsersInstallationConstants.MemberGroups.GroupWebMaster: _logger.Info <SetupDefaultMemberGroupsPermissionsStep>("Setting permissions for Web Master..."); return(SetupWebMasterMemberGroup(group)); case UsersInstallationConstants.MemberGroups.GroupUiPublisher: _logger.Info <SetupDefaultMemberGroupsPermissionsStep>("Setting permissions for UI Publisher..."); return(SetupUiPublisherMemberGroup(group)); case UsersInstallationConstants.MemberGroups.GroupUiUser: _logger.Info <SetupDefaultMemberGroupsPermissionsStep>("Setting permissions for UI User..."); return(SetupUiUserMemberGroup(group)); default: return(null); } }) .WhereNotNull() .SelectMany(p => p); _logger.Info <SetupDefaultMemberGroupsPermissionsStep>($"{permissions.Count()} permissions has been saved"); _permissionsService.Save(permissions); MemoryCache.Default.Trim(100); return(ExecutionResult.Success); }