コード例 #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>
 /// Create a channel in a group
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='groupId'>
 /// </param>
 /// <param name='channelName'>
 /// </param>
 public static void CreateChannel(this IChannels operations, int groupId, string channelName)
 {
     operations.CreateChannelAsync(groupId, channelName).GetAwaiter().GetResult();
 }