示例#1
0
        private async void btnSaveChanges_Click(object sender, RoutedEventArgs e)
        {
            List <int?>   addedUsers      = getAddedUsers();
            List <int?>   removedUsers    = getRemovedUsers();
            List <int?>   addedRoles      = getAddedRoles();
            List <int?>   removedRoles    = getRemovedRoles();
            List <string> addedChannels   = getAddedChannels();
            List <int?>   removedChannels = getRemovedChannels();

            try
            {
                if (addedUsers.Count != 0)
                {
                    await groupsApi.AddUsersToGroupAsync(group.Id, addedUsers);
                }

                if (removedUsers.Count != 0)
                {
                    //await groupsApi.RemoveUsersFromGroupAsync(groupId, removedUsers);
                }

                if (addedRoles.Count != 0)
                {
                    await groupsApi.AddRolesToGroupAsync(group.Id, addedRoles);
                }

                if (removedRoles.Count != 0)
                {
                    //await groupsApi.RemoveRolesFromGroupAsync(groupId, removedRoles);
                }

                foreach (string channelName in addedChannels)
                {
                    await channelsApi.CreateChannelAsync(group.Id, channelName);
                }

                foreach (int channelId in removedChannels)
                {
                    await channelsApi.DeleteChannelAsync(channelId);
                }
            }
            catch (HttpOperationException er)
            {
                new ErrorDialog(er.Response.ReasonPhrase, er.Response.Content).ShowDialog();
                return;
            }

            GroupUpdated?.Invoke(group);
        }
示例#2
0
        private async void btnCreateGroup_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            GroupDTO group = null;

            //Create group
            try
            {
                group = await groupsApi.CreateGroupAsync(new CreateGroupDTO()
                {
                    AllowEmployeeAcknowledgeable = ucGroupSettings.IsAcknowledgeableSelected(),
                    AllowEmployeeBookmark        = ucGroupSettings.IsBookmarkSelected(),
                    AllowEmployeeSticky          = ucGroupSettings.IsStickySelected(),
                    GroupName = ucGroupSettings.GetGroupName()
                });
            }
            catch (HttpOperationException er)
            {
                new ErrorDialog(er.Response.ReasonPhrase, er.Response.Content).ShowDialog();
                return;
            }

            //Add users, roles, and channels
            List <string> channelNames = ucGroupSettings.GetChannels().Select(c => c.Name).ToList();

            try
            {
                await groupsApi.AddUsersToGroupAsync(group.Id, ucGroupSettings.GetSelectedUsers());

                await groupsApi.AddRolesToGroupAsync(group.Id, ucGroupSettings.GetSelectedRoles());

                foreach (string channelName in channelNames)
                {
                    await channelsApi.CreateChannelAsync(group.Id, channelName);
                }
            }
            catch (HttpOperationException er)
            {
                new ErrorDialog(er.Response.ReasonPhrase, er.Response.Content).ShowDialog();
                return;
            }

            MessageBox.Show("The group has now been created!");
            GroupCreated?.Invoke(group);
        }
示例#3
0
 /// <summary>
 /// Add a list of users to a group
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='groupId'>
 /// </param>
 /// <param name='users'>
 /// The list of users to add to the group
 /// </param>
 public static void AddUsersToGroup(this IGroups operations, int groupId, IList <int?> users)
 {
     operations.AddUsersToGroupAsync(groupId, users).GetAwaiter().GetResult();
 }