public void AddUser(string name) { bool userIsBanned = false; foreach (string user in BannedUsers) { if (name == user) { userIsBanned = true; } } if (!userIsBanned) { UserAddedEventArgs args = new UserAddedEventArgs(); args.Name = name; UserAdded(this, args); User newUser = new User(); newUser.Name = name; Users.Add(newUser); } else { UserBannedEventArgs args = new UserBannedEventArgs(); args.Name = name; UserBanned(this, args); } }
static void UserBannedEmail(object sender, UserBannedEventArgs args) { Console.WriteLine($"Email: {args.Name} is banned, and is attempting to join the organization!"); }
static void UserBannedAlarm(object sender, UserBannedEventArgs args) { SystemSounds.Beep.Play(); }