public static bool Run(SvPlayer player, string ExeBy, bool ShowNoPermMessage = false, byte?jobIndex = null)
 {
     if ((player.player.admin && ExeBy.Contains("admins")) || ExeBy.Contains("everyone") || ExeBy.Contains($"username:{player.player.username}"))
     {
         return(true);
     }
     string[] GroupsSplit = ExeBy.Split(',');
     foreach (string name in GroupsSplit)
     {
         if (jobIndex != null)
         {
             if (Groups.Any(curr => $"group:{curr.Value.Name}".Equals(name.Trim()) && curr.Value.Users.Contains(player.playerData.username)) || name == $"jobindex:{jobIndex}")
             {
                 return(true);
             }
         }
         else
         if (Groups.Any(curr => $"group:{curr.Value.Name}".Equals(name.Trim()) && curr.Value.Users.Contains(player.playerData.username)))
         {
             return(true);
         }
     }
     if (ShowNoPermMessage)
     {
         player.SendChatMessage($"<color={errorColor}>{MsgNoPerm}</color>");
     }
     return(false);
 }
Esempio n. 2
0
        private void LogSourceBound(object sender, EventArgs args)
        {
            // update the groups
            Groups.Clear();
            foreach (var group in LogSource.Instance.Logs.Groups
                     .OrderBy(g => g.Name))
            {
                Groups.Add(group);
            }

            // set the selected group
            if (Groups.Any())
            {
                SelectedGroup = Groups[0];
            }

            // update tails
            SetTails();

            // set the selected tail
            if (Tails.Any())
            {
                SelectedTail = Tails[0];
            }
        }
Esempio n. 3
0
        public bool CreateGroup(ItemCollection @group, string name)
        {
            if (Groups.Any())
            {
                var findName = from gro in Groups
                               where gro.GroupName.Contains(name)
                               select gro;
                if (findName.Any())
                {
                    return(false);
                }
            }
            Group newGroup = new Group(name);

            foreach (var user in @group)
            {
                var itIsUser = user as User;
                if (itIsUser != null)
                {
                    itIsUser.GroupMambership = newGroup.GroupName;
                    newGroup.AddMember(itIsUser);
                }
            }
            Groups.Add(newGroup);

            return(true);
        }
Esempio n. 4
0
        private async Task AddAsync()
        {
            try
            {
                if (!Groups.Any(x => x.Checked))
                {
                    WarningMessage = "Please select at least one group.";
                    return;
                }

                await LdapService.AddGroupsAsync(Groups.Where(x => x.Checked).ToList(), CreateEmployees);

                await ToastService.ShowToastAsync("Groups added.", ToastType.Success);

                await SynchronizationService.UpdateGroups(ExceptPageId);

                await ModalDialogService.CloseAsync();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Esempio n. 5
0
        public void AddMenuItem(MenuItem item)
        {
            if (State != MenuState.UnderConstruction)
            {
                throw new ApplicationException("Invalid state for adding menu item");
            }

            if (!Groups.Any(g => g.Id == item.GroupId))
            {
                throw new ArgumentException("Group not found for menu item", nameof(item));
            }

            if (Items.Any(i => i.ProductName == item.ProductName))
            {
                throw new ArgumentException("Menu item with same product name already exists", nameof(item));
            }

            AddAndApplyEvent(new MenuItemAdded
            {
                AggregateRootId = Id,
                Id                 = item.Id,
                GroupId            = item.GroupId,
                ProductName        = item.ProductName,
                ProductDescription = item.ProductDescription,
                Price              = item.Price
            });
        }
Esempio n. 6
0
        public Group CreateGroup(Participant participant, string name, bool closed)
        {
            if (participant.Group != null)
            {
                throw new GoedBezigException("U bent reeds ingeschreven in een groep");
            }

            if (Groups.Any(g => g.Name == name))
            {
                throw new GoedBezigException($"De naam '{name}' is al in gebruik binnen deze organisatie");
            }

            var group = new Group(name, closed);

            Groups.Add(group);
            group.Organization = this;

            // Registering with a closed group requires an invitation
            if (closed)
            {
                group.Invite(participant);
            }

            // FIXME: invitation doesn't get destroyed (because that happens in the controller)
            group.Register(participant);
            return(group);
        }
 /// <summary>
 /// 指定的组是否属于该主题的组
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool IsSelectedGroup(Guid id)
 {
     if (Groups == null || Groups.Count == 0)
     {
         return(false);
     }
     return(Groups.Any(x => x.Id == id));
 }
Esempio n. 8
0
        public bool HasValidFilter()
        {
            if (Count == 0 && Groups == null)
            {
                return(false);
            }

            return(Count > 0 || Groups?.Any(x => x.HasValidFilter()) == true);
        }
Esempio n. 9
0
 public void AddSecurityItem(string name)
 {
     if (!Groups.Any(s => s.Name == name))
     {
         Groups.Add(new GroupItem()
         {
         });
     }
 }
Esempio n. 10
0
        void AddGroups(List <Group> groups)
        {
            if (_groupsByID == null)
            {
                _groupsByID = new Dictionary <int, GroupItem>();
            }

            foreach (var group in groups)
            {
                if (group.IsMainGroupInInstallation)
                {
                    Group = group;
                }

                _groupsByID.Add(group.GroupID, new GroupItem(group));
            }

            Try.NotNull(Group, "Main group not found;", false);

            foreach (var group in groups)
            {
                if (!group.ParentGroupID.HasValue)
                {
                    continue;
                }

                var item       = _groupsByID[group.GroupID];
                var parentItem = _groupsByID[group.ParentGroupID.Value];
                if (parentItem.Groups == null)
                {
                    parentItem.Groups = new List <GroupItem>();
                }
                parentItem.Groups.Add(item);
                item.Parent = parentItem;
            }

            if (_groupsByID.Any())
            {
                Groups = _groupsByID.Values.Cast <GroupItem>()
                         .Where(x => x.Parent == null && !x.IsMainGroupInInstallation)
                         .ToList();

                if (!Groups.Any())
                {
                    Groups = null;
                }
                else
                {
                    foreach (var topChild in Groups)
                    {
                        topChild.Parent = this;
                    }
                }
            }
        }
Esempio n. 11
0
 public bool IsCharactersGroupFull(long characterId)
 {
     if (Groups != null)
     {
         return(Groups.Any(g => g.IsMemberOfGroup(characterId) && g.CharacterCount == 3));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 12
0
 public bool IsCharacterMemberOfGroup(long characterId)
 {
     if (Groups != null)
     {
         return(Groups.Any(g => g.IsMemberOfGroup(characterId)));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 13
0
 private void UpdateAddGroupCommandCanExecute()
 {
     if (!string.IsNullOrEmpty(_newGroupName) && !Groups.Any(group => group.Name == _newGroupName))
     {
         AddGroupCommand.CanBeExecuted = true;
     }
     else
     {
         AddGroupCommand.CanBeExecuted = false;
     }
 }
Esempio n. 14
0
    public void DrawInspector(Rect rect)
    {
        var d = InvertGraphEditor.PlatformDrawer as UnityDrawer;
          //  d.DrawStretchBox(rect, CachedStyles.WizardListItemBoxStyle, 10);
        if (Groups == null || !Groups.Any())
        {
                var textRect = rect;
                var cacheColor = GUI.color;
                GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.4f);
                d.DrawLabel(textRect, "No Items Selected", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.MiddleCenter);
                GUI.color = cacheColor;
                return;
        }

        var groupRect = rect.WithHeight(30);

        foreach (var group in Groups)
        {

            if (GUIHelpers.DoToolbarEx(group.Key, groupRect))
            {
                var itemRect = rect.WithHeight(17).Below(groupRect);

                foreach (var item in group)
                {

                    Rect inspBounds;
                    if (item.InspectorType == InspectorType.GraphItems)
                    {
                        itemRect = itemRect.WithHeight(30);
                    }
                    else if (item.InspectorType == InspectorType.TextArea)
                    {
                        itemRect = itemRect.WithHeight(60);
                    }
                    else
                    {
                        itemRect = itemRect.WithHeight(17);
                    }
                    d.DrawInspector(itemRect, item, EditorStyles.label);
                    itemRect = itemRect.Below(itemRect).Translate(0,3).WithHeight(17);
                }

                groupRect = groupRect.Below(itemRect.Above(itemRect));

            }
            else
            {
                groupRect = groupRect.Below(groupRect);
            }

        }
    }
Esempio n. 15
0
        public override IEnumerable <GeneratorGroup> Generate(MapGenerator generator)
        {
            Random random    = generator.Random;
            double x         = random.NextDouble();
            var    selection = GroupGenerator.Generators.Where(gen => gen.Weight > 0 && gen.FitsRequirements(generator.Feelings)).ToList();

            bool canStripe = true;

            if (Groups.Any() && x < ChanceRequired) //Just the required one
            {
                canStripe = false;
            }
            else if (x < ChanceRequired + ChanceMultiple) //Multiple
            {
                int groups = random.Next(GroupMin, GroupMax + 1);
                for (int i = 0; i < groups; i++)
                {
                    if (selection.Count > 0)
                    {
                        Groups.Add(selection.PickAndRemove(random));
                    }
                }

                canStripe = true;
            }
            else //Only one
            {
                if (selection.Count > 0)
                {
                    Groups.Add(selection.PickAndRemove(random));
                }

                canStripe = Groups.Count >= 2;
            }

            if (canStripe && random.NextDouble() < ChanceStripe)
            {
                int n       = Groups.Count;
                int repeats = random.Next(RepeatMin, RepeatMax + 1);
                for (int e = 0; e < repeats; e++)
                {
                    for (int i = 0; i < n; i++)
                    {
                        Groups.Add(Groups[i]);
                    }
                }
            }

            return(base.Generate(generator));
        }
Esempio n. 16
0
        public override string ToString()
        {
            var counter = 0;

            foreach (var c in Conditions)
            {
                foreach (var definition in c.ParameterDefinitions)
                {
                    definition.Params = $"@p{counter++}";
                }
            }

            return((GroupType.ToString().ToUpperInvariant() ?? "") + " " + "(" + string.Join("\n", Conditions) +
                   (Groups.Any() ? "\n" + string.Join("\n", Groups) : string.Empty) + ")");
        }
Esempio n. 17
0
        public virtual ScreenGroup AddNewGroup(ScreenGroup group)
        {
            if (Groups.Any(a => a.Id == group.Id))
            {
                throw new ArgumentException("Cannot add duplicate group to medium.", "group");
            }

            TrackingState = TrackingState.Added;
            Groups.Add(group);

            var groupUpdatedEvent = new GroupUpdatedEvent(group);

            DomainEvents.Raise(groupUpdatedEvent);

            return(group);
        }
Esempio n. 18
0
        public static void CreateNewGroup(dynamic metadata, dynamic content)
        {
            var groupName = content.Group.ToString();
            var id        = metadata.ReferenceKey.ToString();

            if (!Groups.Any(t => t.GroupKey == groupName))
            {
                var group = new GroupItem {
                    Id = id, GroupKey = groupName, MemberKey = groupName
                };
                Groups.Add(group);
                SendFeedbackMessage(type: MsgType.Success, actionTime: GetCreateDate(metadata), action: MapAction.GroupFeedback.NewGroupAdded.Name, content: group);
            }
            else
            {
                SendFeedbackMessage(type: MsgType.Error, actionTime: GetCreateDate(metadata), action: MapAction.GroupFeedback.CannotAddGroup.Name, content: "Cannot add dupicate Group item!");
            }
        }
Esempio n. 19
0
        // This generates based on criteria for the entire item index.
        /// <summary>
        /// Generates a new <see cref="Catalog"/>.
        /// </summary>
        public Catalog Generate()
        {
            IEnumerable <Item> loot = Engine.Items
                                      .Where(delegate(KeyValuePair <string, Item> x)
            {
                if (x.Value.Dimension != Dimension)
                {
                    return(false);
                }

                if (RequiredTags != 0)
                {
                    if (!x.Value.Tag.HasFlag(RequiredTags))
                    {
                        return(false);
                    }
                }

                if (!(Groups?.Any(t => x.Value.Tag.HasFlag(t)) ?? true))
                {
                    return(false);
                }

                return(true);
            }).Select(x => x.Value);

            List <Item> catalog = MaxStack <= 0 ?
                                  Randomizer.ChooseMany(loot, Size, true).ToList() :
                                  Randomizer.ChooseMany(loot, Size, MaxStack).ToList();

            var items = new Dictionary <Item, int>();

            foreach (Item item in catalog)
            {
                if (items.ContainsKey(item))
                {
                    continue;
                }

                items.Add(item, catalog.Count(x => x == item));
            }

            return(new Catalog(items));
        }
Esempio n. 20
0
        public void UpdateStatuses()
        {
            if (Groups == null || !Groups.Any())
            {
                UpdateStatus();
            }
            else
            {
                var itemsStatusQueue = new List <BaseGroupItem>();

                var allGroups = GetAllGroups();
                itemsStatusQueue.AddRange(allGroups);

                foreach (var item in itemsStatusQueue.AsEnumerable().Reverse())
                {
                    item.UpdateStatus();
                }
            }
        }
Esempio n. 21
0
        public void AddMenuGroup(MenuGroup group)
        {
            if (State != MenuState.UnderConstruction)
            {
                throw new ApplicationException("Invalid state for adding menu group");
            }

            if (Groups.Any(g => g.Name == group.Name))
            {
                throw new ArgumentException("Group with same name already exists", nameof(group));
            }

            AddAndApplyEvent(new MenuGroupAdded
            {
                AggregateRootId = Id,
                Id   = group.Id,
                Name = group.Name
            });
        }
        public Result <bool> AddGroup(string name)
        {
            var errors = new List <string>();

            if (Groups.Any(group => group.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
            {
                errors.Add("This group already exists");
            }

            if (errors.Any())
            {
                return(Result <bool> .Fail(errors));
            }

            var result = Group.Create(name);

            //GroupInternal.Add(result.Value);
            return(Result <bool> .Success(true));
        }
Esempio n. 23
0
        internal IEnumerable <KeyValuePair <string, string> > GetUserFormValues()
        {
            if (!string.IsNullOrWhiteSpace(DisplayName))
            {
                yield return(new KeyValuePair <string, string>("name", DisplayName));
            }

            if (!string.IsNullOrWhiteSpace(Password))
            {
                yield return(new KeyValuePair <string, string>("password", Password));
            }

            if (Roles?.Any() ?? false)
            {
                yield return(new KeyValuePair <string, string>("roles", string.Join(",", Roles !)));
            }

            if (Groups?.Any() ?? false)
            {
                yield return(new KeyValuePair <string, string>("groups", string.Join(",", Groups !)));
            }
        }
Esempio n. 24
0
        public void UpdateStatus()
        {
            ClearStatus();
            bool isStatusInited = false;

            if (Groups != null && Groups.Any())
            {
                foreach (var childGroupWithStatus in Groups.Where(x => x.HasStatus))
                {
                    if (isStatusInited)
                    {
                        UpdateStatusFromGroup(childGroupWithStatus);
                    }
                    else
                    {
                        InitStatusFromGroup(childGroupWithStatus);
                        isStatusInited = true;
                    }
                    HasStatus = true;
                }
            }

            if (PowerBars != null && PowerBars.Any())
            {
                if (!isStatusInited)
                {
                    InitStatusFromPowerBar(PowerBars.First());
                    isStatusInited = true;
                }

                foreach (var childPowerBar in PowerBars)
                {
                    UpdateStatusFromPowerBar(childPowerBar);
                }

                HasStatus = true;
            }
        }
Esempio n. 25
0
        private void TxtGroups_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            string[] groups = txtGroups.Text.Split(';');

            if (e.Key == System.Windows.Input.Key.Enter)
            {
                txtGroups.Text = "";

                foreach (var group in groups)
                {
                    if (!string.IsNullOrEmpty(group) && Groups.Any(g => g.Name.Equals(group)) == false)
                    {
                        Groups.Add(new Group(group));
                    }
                }
            }

            if (Groups.Count > 0 && Groups[0] == null)
            {
                Groups = null;
            }

            tcGroups.ItemsSource = Groups;
        }
            protected override IEnumerable <string> GetParts()
            {
                if (Aggregates.Any())
                {
                    var aggregate = $"aggregate({String.Join(",", Aggregates)})";

                    if (Groups.Any())
                    {
                        aggregate = $"groupby(({String.Join(",", Groups)}),{aggregate})";
                    }

                    if (Filter.Any())
                    {
                        aggregate = $"filter({String.Join(" and ", Filter)})/{aggregate}";
                    }

                    yield return("$apply=" + aggregate);

                    yield break;
                }

                foreach (var part in base.GetParts())
                {
                    yield return(part);
                }

                if (OrderBy.Any())
                {
                    yield return("$orderby=" + String.Join(",", OrderBy));
                }

                if (Top != null)
                {
                    yield return("$top=" + Top);
                }
            }
 public override string ToString()
 {
     return(GroupType.ToString().ToUpperInvariant() + " (" + string.Join(" ", Conditions) +
            (!Groups.Any() ? string.Empty : " " + string.Join(" ", Groups)) + ")");
 }
Esempio n. 28
0
        /// <summary>
        /// Checks a player's permission.
        /// </summary>
        /// <param name="player">The player to be checked.</param>
        /// <param name="permission">The permission to be checked.</param>
        /// <returns>Returns a value indicating whether the user has the permission or not.</returns>
        public static bool CheckPermission(this Player player, string permission)
        {
            if (player == null)
            {
                return(false);
            }

            if (player.GameObject == PlayerManager.localPlayer)
            {
                return(true);
            }

            Log.Debug($"Player: {player.Nickname} UserID: {player.UserId}", Loader.ShouldDebugBeShown);

            if (string.IsNullOrEmpty(permission))
            {
                Log.Error("Permission checked was null.");
                return(false);
            }

            Log.Debug($"Permission string: {permission}", Loader.ShouldDebugBeShown);

            UserGroup userGroup = ServerStatic.GetPermissionsHandler().GetUserGroup(player.UserId);
            Group     group     = null;

            if (userGroup != null)
            {
                Log.Debug($"UserGroup: {userGroup.BadgeText}", Loader.ShouldDebugBeShown);

                string groupName = ServerStatic.GetPermissionsHandler()._groups.FirstOrDefault(g => g.Value == player.Group).Key;

                Log.Debug($"GroupName: {groupName}", Loader.ShouldDebugBeShown);

                if (Groups == null)
                {
                    Log.Error("Permissions config is null.");
                    return(false);
                }

                if (!Groups.Any())
                {
                    Log.Error("No permission config groups.");
                    return(false);
                }

                if (!Groups.TryGetValue(groupName, out group))
                {
                    Log.Error($"Could not get \"{groupName}\" permission");
                    return(false);
                }

                Log.Debug($"Got group.", Loader.ShouldDebugBeShown);
            }
            else
            {
                Log.Debug("Player group is null, getting default..", Loader.ShouldDebugBeShown);

                group = DefaultGroup;
            }

            if (group != null)
            {
                Log.Debug("Group is not null!", Loader.ShouldDebugBeShown);

                if (permission.Contains("."))
                {
                    Log.Debug("Group contains permission separator", Loader.ShouldDebugBeShown);

                    if (group.CombinedPermissions.Any(s => s == ".*"))
                    {
                        Log.Debug("All permissions have been granted for all nodes.", Loader.ShouldDebugBeShown);
                        return(true);
                    }

                    if (group.CombinedPermissions.Contains(permission.Split('.')[0] + ".*"))
                    {
                        Log.Debug("Check 1: True, returning.", Loader.ShouldDebugBeShown);
                        return(true);
                    }
                }

                if (group.CombinedPermissions.Contains(permission) || group.CombinedPermissions.Contains("*"))
                {
                    Log.Debug("Check 2: True, returning.", Loader.ShouldDebugBeShown);
                    return(true);
                }
            }
            else
            {
                Log.Debug("Group is null, returning false.", Loader.ShouldDebugBeShown);
                return(false);
            }

            Log.Debug("No permissions found.", Loader.ShouldDebugBeShown);

            return(false);
        }
 public AddEditUserViewModel(IUsersService usersService, IGroupsService groupsService)
 {
     _usersService  = usersService;
     _groupsService = groupsService;
     CancelCommand  = new RelayCommand(OnCancel);
     SaveCommand    = new RelayCommand(OnSave, CanSave);
     GroupsDropDownOpenedCommand = new RelayCommand(OnGroupsDropDownOpened, () => Groups != null && Groups.Any());
 }
Esempio n. 30
0
        /// <summary>
        /// Criando regras iniciais e de testes
        /// </summary>
        private void Seed_Security()
        {
            if (!Groups.Any())
            {
                var groups = new Group[]
                {
                    new Group {
                        Name = "Security"
                    },
                    new Group {
                        Name = "Management"
                    },
                    new Group {
                        Name = "Configuration"
                    },
                    new Group {
                        Name = "Sales"
                    },
                    new Group {
                        Name = "Operation"
                    }
                };

                Groups.AddRange(groups);

                foreach (var enterprise in Enterprises)
                {
                    var name = enterprise.Name.EndsWith('s')
                        ? enterprise.Name + "\'s"
                        : enterprise.Name;

                    var group = new Group
                    {
                        Name       = $"{name} User",
                        Enterprise = enterprise
                    };

                    Groups.Add(group);
                }

                SaveChanges();
            }

            if (IsTest)
            {
                if (!Users.Any())
                {
                    {
                        var enterprise = Enterprises
                                         .Single(e => e.Name == "Enterprise Test");

                        var email = $"user@{enterprise.Name}.com".Replace(" ", "").ToLower();

                        var user = new User
                        {
                            Name       = "User",
                            PublicId   = CryptoHelper.Guid("U$1"),
                            PrivateId  = CryptoHelper.Guid("U$1"),
                            Email      = email,
                            Password   = CryptoHelper.Guid("user2019"),
                            Enterprise = enterprise
                        };

                        Users.Add(user);
                    }

                    foreach (var group in Groups
                             .Where(e => e.EnterpriseId == null))
                    {
                        foreach (var enterprise in Enterprises)
                        {
                            var email = $"{group.Name}@{enterprise.Name}.com".Replace(" ", "").ToLower();

                            var user = new User
                            {
                                Name       = group.Name,
                                PublicId   = CryptoHelper.Guid(group.Name + "#" + enterprise.Name),
                                PrivateId  = CryptoHelper.Guid(group.Name + "$" + enterprise.Name),
                                Email      = email,
                                Password   = CryptoHelper.Guid(group.Name.ToLower()),
                                Enterprise = enterprise
                            };

                            Users.Add(user);

                            var userGroup = new UserGroup
                            {
                                User  = user,
                                Group = group
                            };

                            UserGroups.AddRange(userGroup);
                        }
                    }

                    SaveChanges();
                }
            }

            if (!Areas.Any())
            {
                var areas = new Area[]
                {
                    new Area {
                        Id   = (int)AreaEnum.User,
                        Name = "User"
                    },
                    new Area {
                        Id   = (int)AreaEnum.Group,
                        Name = "Group"
                    },
                    new Area {
                        Id   = (int)AreaEnum.Customer,
                        Name = "Customer"
                    }
                };

                Areas.AddRange(areas);

                SaveChanges();
            }

            if (IsTest)
            {
                if (!AreaAccess.Any())
                {
                    // Sales tem acesso de leitura e escrita no CRM

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.Customer);

                        var group = Groups
                                    .First(e => e.Name == "Sales");

                        var areaAccess = new AreaAccess
                        {
                            Area      = area,
                            Group     = group,
                            CanCreate = true,
                            CanDelete = false,
                            CanModify = true,
                            CanRead   = true
                        };

                        AreaAccess.Add(areaAccess);
                    }

                    // Management tem acesso completo ao CRM

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.Customer);

                        var group = Groups
                                    .First(e => e.Name == "Management");

                        var areaAccess = new AreaAccess
                        {
                            Area      = area,
                            Group     = group,
                            CanCreate = true,
                            CanDelete = true,
                            CanModify = true,
                            CanRead   = true
                        };

                        AreaAccess.Add(areaAccess);
                    }

                    // Operation só pode consultar o CRM

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.Customer);

                        var group = Groups
                                    .First(e => e.Name == "Operation");

                        var areaAccess = new AreaAccess
                        {
                            Area      = area,
                            Group     = group,
                            CanCreate = false,
                            CanDelete = false,
                            CanModify = false,
                            CanRead   = true
                        };

                        AreaAccess.Add(areaAccess);
                    }

                    // Segurança pode criar novos grupos

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.Group);

                        var group = Groups
                                    .First(e => e.Name == "Security");

                        var areaAccess = new AreaAccess
                        {
                            Area      = area,
                            Group     = group,
                            CanCreate = true,
                            CanDelete = true,
                            CanModify = true,
                            CanRead   = true
                        };

                        AreaAccess.Add(areaAccess);
                    }

                    // Segurança pode criar novos usuários

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.User);

                        var group = Groups
                                    .First(e => e.Name == "Security");

                        var areaAccess = new AreaAccess
                        {
                            Area      = area,
                            Group     = group,
                            CanCreate = true,
                            CanDelete = true,
                            CanModify = true,
                            CanRead   = true
                        };

                        AreaAccess.Add(areaAccess);
                    }

                    SaveChanges();
                }
            }

            if (!Policies.Any())
            {
                var area = Areas
                           .Find((int)AreaEnum.User);

                var policies = new Policy[]
                {
                    new Policy {
                        Id   = (int)PolicyEnum.User_ChangePassword,
                        Area = area,
                        Name = "Change Password"
                    },
                    new Policy {
                        Id   = (int)PolicyEnum.User_ChangeEmail,
                        Area = area,
                        Name = "Change Email"
                    }
                };

                Policies.AddRange(policies);

                SaveChanges();
            }

            if (IsTest)
            {
                if (!PolicyAccess.Any())
                {
                    // Segurança tem acesso às políticas de segurança

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.User);

                        var group = Groups
                                    .First(e => e.Name == "Security");

                        foreach (var policy in Policies
                                 .Where(e => e.AreaId == area.Id))
                        {
                            var policyAccess = new PolicyAccess
                            {
                                Group  = group,
                                Policy = policy
                            };

                            PolicyAccess.AddRange(policyAccess);
                        }
                    }

                    SaveChanges();
                }
            }
        }