public static AddEditWindow CreateEditWindow(Subscriber subscriber, ISubscriberValidator validator) { var window = new AddEditWindow { Validator = validator }; window.PopulateWithSubscriberData(subscriber); return(window); }
private void addBtn_Click(object sender, RoutedEventArgs e) { var validator = new UniqueUsernameValidator(subscribers); var addWindow = AddEditWindow.CreateAddWindow(validator); if (addWindow.ShowDialog() == true) { subscribers.Add(addWindow.Subscriber); UpdateItems(); } }
private void editBtn_Click(object sender, RoutedEventArgs e) { var subscriber = (Subscriber)subscribersLB.SelectedItem; var validator = new UniqueUsernameValidator(subscribers, subscriber.Name); var editWindow = AddEditWindow.CreateEditWindow(subscriber, validator); if (editWindow.ShowDialog() == true) { subscribers.RemoveByName(subscriber.Name); var newSubscriber = editWindow.Subscriber; subscribers.Add(newSubscriber); UpdateItems(); } }