Ejemplo n.º 1
0
        public ReworkProductsVM(ReworkVM rework, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentRework = rework;
            ReworkDataService = new ReworkDataService(UnitOfWork);
            ReworkDataService.ProductAdded += OnProductAdded;
            ReworkDataService.ProductRemoved += OnProductRemoved;
            ProductDataService = new ProductDataService(UnitOfWork);
            ProductReworkDataService = new ProductReworkDataService(UnitOfWork);
            ProductGroupDataService = new ProductGroupDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ProductReworkVM>();
            foreach (var reworkProduct in ReworkDataService.GetProducts(rework.Id))
            {
                selectedVms.Add(new ProductReworkVM(reworkProduct, Access,ProductReworkDataService, RelationDirection.Reverse));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<ProductVM>();
            foreach (var product in ProductDataService.GetActives(SoheilEntityType.Reworks, CurrentRework.Id))
            {
                allVms.Add(new ProductVM(product, Access, ProductDataService, ProductGroupDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
Ejemplo n.º 2
0
 private void OnReworkAdded(object sender, ModelAddedEventArgs<Rework> e)
 {
     var newReworkVm = new ReworkVM(e.NewModel, Access, ReworkDataService);
     Items.AddNewItem(newReworkVm);
     Items.CommitNew();
     CurrentContent = newReworkVm;
     CurrentContent.IsSelected = true;
 }
Ejemplo n.º 3
0
 private void OnReworkRemoved(object sender, ModelRemovedEventArgs e)
 {
     foreach (ProductReworkVM item in SelectedItems)
     {
         if (item.Id == e.Id)
         {
             var model = ReworkDataService.GetSingle(item.ReworkId);
             var returnedVm = new ReworkVM(model, Access, ReworkDataService);
             AllItems.AddNewItem(returnedVm);
             AllItems.CommitNew();
             SelectedItems.Remove(item);
             break;
         }
     }
 }