Exemplo n.º 1
0
        public static AddEditWindow CreateEditWindow(Subscriber subscriber,
                                                     ISubscriberValidator validator)
        {
            var window = new AddEditWindow
            {
                Validator = validator
            };

            window.PopulateWithSubscriberData(subscriber);
            return(window);
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        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();
            }
        }