Exemplo n.º 1
0
        public SpecificationMainViewModel(IEventAggregator aggregator,
                                          IDataService <LabDbEntities> labDbData,
                                          ISpecificationService specificationService)
            : base()
        {
            _labDbData            = labDbData;
            _eventAggregator      = aggregator;
            _specificationService = specificationService;

            NewSpecificationCommand = new DelegateCommand(
                () =>
            {
                _specificationService.CreateSpecification();
            },
                () => Thread.CurrentPrincipal.IsInRole(UserRoleNames.SpecificationEdit));

            OpenSpecificationCommand = new DelegateCommand <Specification>(
                spec =>
            {
                NavigationToken token = new NavigationToken(SpecificationViewNames.SpecificationEdit,
                                                            SelectedSpecification);
                _eventAggregator.GetEvent <NavigationRequested>().Publish(token);
            });

            #region EventSubscriptions

            _eventAggregator.GetEvent <SpecificationChanged>()
            .Subscribe(token =>
            {
                RaisePropertyChanged("SpecificationList");
            });

            #endregion EventSubscriptions
        }