Ejemplo n.º 1
0
        private void AddUnassignedGroupUsersItem()
        {
            Guid           unassignedGroupId        = new Guid();
            GroupItem      unassignedGroupItem      = new GroupItem(unassignedGroupId, _unassignedGroupName);
            GroupUsersItem unassignedGroupUsersItem = new GroupUsersItem(unassignedGroupItem);

            GroupUsersItems.Add(unassignedGroupUsersItem);
        }
Ejemplo n.º 2
0
        public void RemoveGroup(GroupItem groupItem)
        {
            if (GroupUsersItems.Select(i => i.GroupItem).Any(u => u.Id == groupItem.Id && u.GroupName == groupItem.GroupName))
            {
                //TOdo check assigments
                //if (IfUserHasAnyAssignment(userToRemove))
                //{
                //    return;
                //}

                GroupUsersItem itemTorRemove = GroupUsersItems.First(i =>
                                                                     i.GroupItem.Id == groupItem.Id && i.GroupItem.GroupName == groupItem.GroupName);

                GroupUsersItems.Remove(itemTorRemove);
            }
        }
Ejemplo n.º 3
0
        public void AddUser(GroupItem groupItem, UserItem userItem)
        {
            if (DoesUserItemExist(userItem) == false || IsGroupItemCorrect(groupItem) == false || IsUserItemCorrect(userItem) == false)
            {
                return;
            }

            if (GroupUsersItems.Any(g => g.GroupItem.Id == groupItem.Id))
            {
                GroupUsersItem existingGroup = GroupUsersItems.First(g => g.GroupItem.Id == groupItem.Id);
                existingGroup.AddUserIfNotExists(userItem);
            }
            else
            {
                GroupUsersItems.Add(new GroupUsersItem(groupItem, userItem));
            }
        }
Ejemplo n.º 4
0
        public void RemoveUser(string fullName, string email)
        {
            if (GroupUsersItems.SelectMany(i => i.UserItems).Any(u => u.FullName == fullName && u.Email == email))
            {
                UserItem userToRemove = GroupUsersItems.SelectMany(i => i.UserItems)
                                        .First(u => u.FullName == fullName && u.Email == email);

                if (IfUserHasAnyAssignment(userToRemove))
                {
                    return;
                }

                GroupUsersItem unassignedGroupUsersItem =
                    GroupUsersItems.First(i => i.GroupItem.GroupName == _unassignedGroupName);
                unassignedGroupUsersItem.UserItems.Remove(userToRemove);
            }
        }
Ejemplo n.º 5
0
        public void AddUser(string groupName, UserItem userItem)
        {
            if (GroupUsersItems.SelectMany(i => i.UserItems).Any(u => (u.FullName == userItem.FullName && u.Email == userItem.Email) || (u.Id == userItem.Id)))
            {
                return;
            }

            if (GroupUsersItems.Any(g => g.GroupItem.GroupName == groupName))
            {
                GroupUsersItem existingGroup = GroupUsersItems.First(g => g.GroupItem.GroupName == groupName);
                existingGroup.AddUserIfNotExists(userItem);
            }
            else
            {
                GroupItem groupItem = new GroupItem(Guid.NewGuid(), groupName);
                GroupUsersItems.Add(new GroupUsersItem(groupItem, userItem));
            }
        }