private void BtnOk_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(UsernameText.Text)) { MessageBox.Show("You must enter a name!", "Invalid Name", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (AllUsers.Any(u => u.Username.Equals(UsernameText.Text, StringComparison.CurrentCultureIgnoreCase))) { MessageBox.Show("A user with that name already exists!", "Duplicate Name", MessageBoxButton.OK, MessageBoxImage.Warning); return; } Username = UsernameText.Text; Close(); }
public bool UserHasRequested(string username) { return(AllUsers.Any(x => x.Equals(username, StringComparison.OrdinalIgnoreCase))); }