示例#1
0
        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);
        }
示例#2
0
        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);
        }