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); }
private void UpdateBannedGuildsAndPeoples() { foreach (var bannedGuild in BannedGuilds.ToArray()) { var guild = _explorer.GetGuild(Region.EU, bannedGuild.Realm, bannedGuild.Name, GuildOptions.GetMembers); Parallel.ForEach(guild.Members, member => { member.FullCharactor = _explorer.GetCharacter(Region.EU, member.GuildCharacter.Realm, member.GuildCharacter.Name, CharacterOptions.GetPetSlots); }); BannedGuilds.Remove(bannedGuild); BannedGuilds.Add(guild); } foreach (var bannedPlayer in BannedPlayers.ToArray()) { var updated = _explorer.GetCharacter(bannedPlayer.Realm, bannedPlayer.Name, CharacterOptions.GetPetSlots); BannedPlayers.Remove(bannedPlayer); BannedPlayers.Add(updated); } }