public InstrumentMainViewModel(IDataService <LabDbEntities> labDbData, IEventAggregator eventAggregator, InstrumentService instrumentService) : base() { _eventAggregator = eventAggregator; _labDbData = labDbData; _instrumentService = instrumentService; DeleteInstrumentCommand = new DelegateCommand( () => { _selectedInstrument.Delete(); SelectedInstrument = null; }, () => IsInstrumentAdmin && _selectedInstrument != null); NewInstrumentCommand = new DelegateCommand( () => { _instrumentService.CreateInstrument(); }, () => IsInstrumentAdmin); OpenInstrumentCommand = new DelegateCommand( () => { NavigationToken token = new NavigationToken(InstrumentViewNames.InstrumentEditView, SelectedInstrument); _eventAggregator.GetEvent <NavigationRequested>().Publish(token); }, () => SelectedInstrument != null); OpenPendingCommand = new DelegateCommand( () => { NavigationToken token = new NavigationToken(InstrumentViewNames.InstrumentEditView, SelectedPending); _eventAggregator.GetEvent <NavigationRequested>().Publish(token); }); _eventAggregator.GetEvent <CalibrationIssued>().Subscribe( calRep => { RaisePropertyChanged("PendingCalibrationsList"); RaisePropertyChanged("CalibrationsList"); }); _eventAggregator.GetEvent <InstrumentListUpdateRequested>().Subscribe( () => { RaisePropertyChanged("InstrumentList"); RaisePropertyChanged("PendingCalibrationsList"); }); }
public void DeleteTest() { Instrument instrument = new Instrument(); InstrumentList instruments = new InstrumentList(); instruments.Load(); instrument = instruments.FirstOrDefault(i => i.Description == "Update"); int results = instrument.Delete(); Assert.IsTrue(results == 1); }
private void deleteClick(object sender, RoutedEventArgs e) { Button button = sender as System.Windows.Controls.Button; Instrument instrument = button.DataContext as Instrument; if (MessageBox.Show("Are you sure you want to delete this instrument ?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { instrument.Delete(instrument.Id.ToString()); RefreshUserList(); } else { return; } }
private void btnDeleteAll_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Are you sure you want to delete all this information?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { foreach (Instrument u in MetarGrid.SelectedItems) { u.Delete(u.Id.ToString()); } RefreshUserList(); } else { return; } }