Beispiel #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);
        }
        private async void miDeleteChannel_Click(object sender, RoutedEventArgs e)
        {
            var        menuItem = sender as MenuItem;
            ChannelDTO channel  = (ChannelDTO)menuItem.DataContext;

            MessageBoxResult result = MessageBox.Show("Are you sure, you want to delete: " + channel.Name + "?", "Delete channel", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }

            try
            {
                await channelsApi.DeleteChannelAsync(channel.Id);

                MessageBox.Show("The channel was succesfully deleted!", "Delete channel");
                await update();
            }
            catch (HttpOperationException er)
            {
                new ErrorDialog(er.Response.ReasonPhrase, er.Response.Content).ShowDialog();
            }
        }
 /// <summary>
 /// Delete a channel from a group
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='channelId'>
 /// The id of the channel to delete
 /// </param>
 public static void DeleteChannel(this IChannels operations, int channelId)
 {
     operations.DeleteChannelAsync(channelId).GetAwaiter().GetResult();
 }