Beispiel #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);
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 /// <param name="dataService"></param>
 /// <param name="presentationType"></param>
 public ProductReworkVM(ProductRework entity, AccessType access, ProductReworkDataService dataService, RelationDirection presentationType):base(access, presentationType)
 {
     InitializeData(dataService);
     _model = entity;
     ProductId = entity.Product.Id;
     ReworkId = entity.Rework.Id;
     ProductName = entity.Product.Name;
     ProductCode = entity.Product.Code;
     ReworkName = entity.Rework.Name;
     ReworkCode = entity.Rework.Code;
 }
Beispiel #3
0
 private void InitializeData(ProductReworkDataService dataService)
 {
     DataService = dataService;
     SaveCommand = new Command(Save, CanSave);
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values.
 /// </summary>
 public ProductReworkVM(AccessType access, ProductReworkDataService dataService, RelationDirection presentationType)
     : base(access, presentationType)
 {
     InitializeData(dataService);
 }