private async void Disconnect() { ChatControl chatWindow = new ChatControl(ChatsControl); MainWindow mainWindow = new MainWindow(); SignalRManager signalRManager = new SignalRManager(); string chatName = Command["objectName"]; string userName = User.Name; if (chatName == string.Empty) { chatName = ChatSelected; } if (chatName != string.Empty) { await ApiManager.Delete("api/chat", $"removeUserFromChat/{chatName}/{userName}"); chatWindow.DeleteTabItem(chatName); signalRManager.RemoveUserFromChat(chatName, userName); } else { MessageBox.Show("Подключитесь к комнате или введите корректное название."); } }
private async void Delete() { ChatControl chatWindow = new ChatControl(ChatsControl); string chatName = Command["objectName"]; bool hasRight = Convert.ToBoolean(await ApiManager.Read($"api/chat/hasHighRightInChat/{chatName}/{User.Name}")); if (hasRight) { if (chatName != string.Empty) { SignalRManager signalRManager = new SignalRManager(); ApiManager.Delete("api/chat", $"deleteChat/{chatName}/{User.Name}"); chatWindow.DeleteTabItem(chatName); signalRManager.RemoveChat(chatName); } else { MessageBox.Show("Некорректное имя."); } } else { MessageBox.Show("У вас нет прав на это действие."); } }