public ActionPlanFishbonesVM(ActionPlanVM actionPlan, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentActionPlan = actionPlan;
            ActionPlanDataService = new ActionPlanDataService(UnitOfWork);
            ActionPlanDataService.FishboneNodeAdded += OnFishboneNodeAdded;
            ActionPlanDataService.FishboneNodeRemoved += OnFishboneNodeRemoved;
            FishboneActionPlanDataService = new FishboneActionPlanDataService(UnitOfWork);
            FishboneNodeDataService = new FishboneNodeDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ActionPlanFishboneVM>();
            foreach (var fishboneNodeActionPlan in ActionPlanDataService.GetFishboneNodes(actionPlan.Id))
            {
                selectedVms.Add(new ActionPlanFishboneVM(fishboneNodeActionPlan,access,RelationDirection.Straight));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<FishboneNodeVM>();
            foreach (var fishboneNode in FishboneNodeDataService.GetActives())
            {
                allVms.Add(new FishboneNodeVM(fishboneNode, Access, FishboneNodeDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
Beispiel #2
0
 private void OnActionPlanAdded(object sender, ModelAddedEventArgs<ActionPlan> e)
 {
     var newActionPlanVm = new ActionPlanVM(e.NewModel, Access, ActionPlanDataService);
     Items.AddNewItem(newActionPlanVm);
     Items.CommitNew();
     CurrentContent = newActionPlanVm;
     CurrentContent.IsSelected = true;
 }