private void RemoveGuildToBan(object sender, RoutedEventArgs e) { var guildForRemove = BannedGuilds.FirstOrDefault( guild => guild.Name.ToLower() == GuildNameTextBox.Text.ToLower() && guild.Name.ToLower() == SelectedGuildServerName.ToLower()); if (guildForRemove == null) { MessageBox.Show("Гильдия не найдена"); return; } BannedGuilds.Remove(guildForRemove); }
private void AddGuildToBan(object sender, RoutedEventArgs e) { var bannedGuildName = GuildNameTextBox.Text; var bGuild = BannedGuilds.FirstOrDefault(g => string.Equals(g.Name, bannedGuildName, StringComparison.OrdinalIgnoreCase) && string.Equals(g.Realm, SelectedGuildServerName, StringComparison.OrdinalIgnoreCase)); if (bGuild != null) { MessageBox.Show("Данная гильдия уже добавлена"); return; } var newGuild = new Guild { Name = bannedGuildName, Realm = SelectedGuildServerName }; BannedGuilds.Add(newGuild); }