Exemplo n.º 1
0
        public ActivityOperatorsVM(ActivityVM activity, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentActivity = activity;
            ActivityDataService = new ActivityDataService(UnitOfWork);
            ActivityDataService.OperatorAdded += OnOperatorAdded;
            ActivityDataService.OperatorRemoved += OnOperatorRemoved;
            OperatorDataService = new OperatorDataService(UnitOfWork);
            ActivityOperatorDataService = new ActivitySkillDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ActivityOperatorVM>();
            foreach (var activityOperator in ActivityDataService.GetOperators(activity.Id))
            {
                selectedVms.Add(new ActivityOperatorVM(activityOperator, Access, ActivityOperatorDataService, RelationDirection.Straight));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<OperatorVM>();
            foreach (var opr in OperatorDataService.GetActives(SoheilEntityType.Activities, CurrentActivity.Id))
            {
                allVms.Add(new OperatorVM(opr, Access, OperatorDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
Exemplo n.º 2
0
        private void OnActivityAdded(object sender, ModelAddedEventArgs<Activity> e)
        {
            var newContent = new ActivityVM(e.NewModel, GroupItems, Access, ActivityDataService, ActivityGroupDataService);
            Items.AddNewItem(newContent);
            Items.CommitNew();

            CurrentContent = newContent;
            CurrentContent.IsSelected = true;
        }