public void AddNewPublisher(string publisherName) { Publisher publisher = Publishers.FirstOrDefault(p => p.Name.ToLower() == publisherName.ToLower()); if (publisher != null) { SelectedPublisher = publisher; return; } if (MessageBox.Show(String.Format(App.GetString("AreYouSureAddPublisher"), publisherName), App.GetString("NewPublisher"), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes) { using (var dbService = _dbServiceManager.GetService()) { Publisher newPub = new Publisher() { Name = publisherName }; newPub.Id = dbService.Publishers.Add(newPub); Publishers.Add(newPub); SelectedPublisher = newPub; } } else { SelectedPublisher = null; } }
public void CreateNewPublisher(string name) { Publisher publisher = new Publisher(name); Publishers.Add(publisher); OnPropertyChanged(nameof(Publishers)); SaveDataBase(); }
public PubSubViewModel() { PublishCommand = new ActionCommand() { CanExecuteFunction = e => { return(Publishers.Count > 0); }, ExecuteAction = e => { if (serviceCalls != null) { serviceCalls.Terminator.Cancel(); } serviceCalls = new PublicationPump(() => { Parallel.ForEach(Publishers, x => x.Publish()); }, new TimeSpan(0, 0, 0, 0, 200)); Task.Run(() => serviceCalls.Prime()); } }; AddSubscriberCommand = new ActionCommand() { CanExecuteFunction = e => { return(true); }, ExecuteAction = e => { List <string> channels = new List <string>(); Publishers.ToList().ForEach(x => channels.Add(x.Channel)); Subscribers.Add(new SubscriberExample(channels.ToArray())); OnPropertyChanged(x => x.Subscribers); } }; AddPublisherCommand = new ActionCommand() { CanExecuteFunction = e => { return(true); }, ExecuteAction = e => { Publishers.Add(new ImagePublisherExample() { Channel = $"channel{Publishers.Count}" }); OnPropertyChanged(x => x.Publishers); } }; }
public void CreateNewPublisher(string name) { Publisher newPublisher = new Publisher(name); bool exist = false; foreach (Publisher publisher in Publishers) { if (publisher.Name == name) { exist = true; } } if (!exist) { Publishers.Add(newPublisher); SaveData(); } OnPropertyChanged(nameof(Publishers)); }
public void AddPublisher(Publisher publisher) { Publishers.Add(publisher); SaveChanges(); }
private void onPublisherAdd(Publisher publisher) { Publishers.Add(publisher); }