public SpecificationEditViewModel(IDataService <LabDbEntities> labDbData, IEventAggregator aggregator, IReportService reportService) { _labDbData = labDbData; _eventAggregator = aggregator; _reportService = reportService; AddControlPlanCommand = new DelegateCommand( () => { ControlPlan temp = _instance.AddControlPlan(); RaisePropertyChanged("ControlPlanList"); }); AddFileCommand = new DelegateCommand( () => { OpenFileDialog fileDialog = new OpenFileDialog { Multiselect = true }; if (fileDialog.ShowDialog() == DialogResult.OK) { foreach (string pth in fileDialog.FileNames) { StandardFile temp = new StandardFile { Path = pth, Description = "", StandardID = _instance.StandardID }; temp.Create(); } RaisePropertyChanged("FileList"); } }, () => Thread.CurrentPrincipal.IsInRole(UserRoleNames.SpecificationEdit)); AddTestCommand = new DelegateCommand <MethodVariant>( mtd => { Requirement newReq = _reportService.GenerateRequirement(mtd); _instance.AddMethod(newReq); _eventAggregator.GetEvent <SpecificationMethodListChanged>() .Publish(_instance); }, mtd => CanEdit); AddVersionCommand = new DelegateCommand( () => { SpecificationVersion temp = new SpecificationVersion { IsMain = false, Name = "Nuova versione", SpecificationID = _instance.ID }; temp.Create(); RaisePropertyChanged("VersionList"); }, () => CanEdit); CloseAddMethodViewCommand = new DelegateCommand( () => { NavigationToken token = new NavigationToken(SpecificationViewNames.SpecificationVersionList, null, RegionNames.SpecificationVersionTestListEditRegion); _eventAggregator.GetEvent <NavigationRequested>() .Publish(token); }); OpenFileCommand = new DelegateCommand( () => { try { System.Diagnostics.Process.Start(_selectedFile.Path); } catch (Exception) { _eventAggregator.GetEvent <StatusNotificationIssued>().Publish("File non trovato"); } }, () => _selectedFile != null); OpenReportCommand = new DelegateCommand( () => { NavigationToken token = new NavigationToken(Reports.ViewNames.ReportEditView, SelectedReport); _eventAggregator.GetEvent <NavigationRequested>().Publish(token); }, () => _selectedReport != null); RemoveControlPlanCommand = new DelegateCommand( () => { _selectedControlPlan.Delete(); RaisePropertyChanged("ControlPlanList"); SelectedControlPlan = null; }, () => CanEdit && _selectedControlPlan != null && !_selectedControlPlan.IsDefault); RemoveFileCommand = new DelegateCommand( () => { _selectedFile.Delete(); SelectedFile = null; }, () => Thread.CurrentPrincipal.IsInRole(UserRoleNames.SpecificationEdit) && _selectedFile != null); SaveCommand = new DelegateCommand( () => { _instance.Update(); _instance.Standard.Update(); EditMode = false; }, () => _editMode && !HasErrors); StartEditCommand = new DelegateCommand( () => { EditMode = true; }, () => Thread.CurrentPrincipal.IsInRole(UserRoleNames.SpecificationEdit) && !_editMode); // Event Subscriptions _eventAggregator.GetEvent <MethodChanged>() .Subscribe( tkn => { _methodVariantList = null; RaisePropertyChanged("MethodVariantList"); }); _eventAggregator.GetEvent <ReportCreated>().Subscribe( report => RaisePropertyChanged("ReportList")); }