Пример #1
0
		public MachineStationsVM(MachineVM machine, AccessType access)
			: base(access)
		{
            UnitOfWork = new SoheilEdmContext();
			CurrentMachine = machine;
            MachineDataService = new MachineDataService(UnitOfWork);
			MachineDataService.StationAdded += OnStationAdded;
			MachineDataService.StationRemoved += OnStationRemoved;
            StationDataService = new StationDataService(UnitOfWork);

			var selectedVms = new ObservableCollection<StationMachineVM>();
			foreach (var stationMachine in MachineDataService.GetStations(machine.Id))
			{
				selectedVms.Add(new StationMachineVM(stationMachine, Access, StationMachineDataService, RelationDirection.Reverse));
			}
			SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<StationVM>();
            foreach (var station in StationDataService.GetActives(SoheilEntityType.Machines, CurrentMachine.Id))
            {
                allVms.Add(new StationVM(station, Access, StationDataService));
            }
            AllItems = new ListCollectionView(allVms);

			IncludeCommand = new Command(Include, CanInclude);
			ExcludeCommand = new Command(Exclude, CanExclude);
		}
Пример #2
0
 private void OnMachineAdded(object sender, ModelAddedEventArgs<Machine> e)
 {
     var newMachineVm = new MachineVM(e.NewModel, GroupItems, Access, MachineDataService, MachineFamilyDataService);
     Items.AddNewItem(newMachineVm);
     Items.CommitNew();
     CurrentContent = newMachineVm;
     CurrentContent.IsSelected = true;
 }
Пример #3
0
 private void OnMachineRemoved(object sender, ModelRemovedEventArgs e)
 {
     foreach (StationMachineVM  item in SelectedItems)
     {
         if (item.Id == e.Id)
         {
             var model = MachineDataService.GetSingle(item.MachineId);
             var returnedVm = new MachineVM(model, Access, MachineDataService, MachineFamilyDataService);
             AllItems.AddNewItem(returnedVm);
             AllItems.CommitNew();
             SelectedItems.Remove(item);
             break;
         }
     }
 }