public ProductDefectionsVM(ProductVM product, AccessType access):base(access) { UnitOfWork = new SoheilEdmContext(); CurrentProduct = product; ProductDataService = new ProductDataService(UnitOfWork); ProductDataService.DefectionAdded += OnDefectionAdded; ProductDataService.DefectionRemoved += OnDefectionRemoved; DefectionDataService = new DefectionDataService(UnitOfWork); ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork); var selectedVms = new ObservableCollection<ProductDefectionVM>(); foreach (var productDefection in ProductDataService.GetDefections(product.Id)) { selectedVms.Add(new ProductDefectionVM(productDefection, Access, ProductDefectionDataService, RelationDirection.Straight)); } SelectedItems = new ListCollectionView(selectedVms); var allVms = new ObservableCollection<DefectionVM>(); foreach (var defection in DefectionDataService.GetActives(SoheilEntityType.Products, CurrentProduct.Id)) { allVms.Add(new DefectionVM(defection, Access, DefectionDataService)); } AllItems = new ListCollectionView(allVms); IncludeCommand = new Command(Include, CanInclude); ExcludeCommand = new Command(Exclude, CanExclude); IncludeRangeCommand = new Command(IncludeRange, CanIncludeRange); ExcludeRangeCommand = new Command(ExcludeRange, CanExcludeRange); }
public DefectionProductsVM(DefectionVM defection, AccessType access) : base(access) { UnitOfWork = new SoheilEdmContext(); CurrentDefection = defection; DefectionDataService = new DefectionDataService(UnitOfWork); DefectionDataService.ProductAdded += OnProductAdded; DefectionDataService.ProductRemoved += OnProductRemoved; ProductDataService = new ProductDataService(UnitOfWork); ProductGroupDataService = new ProductGroupDataService(UnitOfWork); ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork); var selectedVms = new ObservableCollection<ProductDefectionVM>(); foreach (var productDefection in DefectionDataService.GetProducts(defection.Id)) { selectedVms.Add(new ProductDefectionVM(productDefection, Access, ProductDefectionDataService, RelationDirection.Reverse)); } SelectedItems = new ListCollectionView(selectedVms); var allVms = new ObservableCollection<ProductVM>(); foreach (var product in ProductDataService.GetActives(SoheilEntityType.Defections, CurrentDefection.Id)) { allVms.Add(new ProductVM(product, Access, ProductDataService, ProductGroupDataService)); } AllItems = new ListCollectionView(allVms); IncludeCommand = new Command(Include, CanInclude); ExcludeCommand = new Command(Exclude, CanExclude); }
private void InitializeData() { UnitOfWork = new SoheilEdmContext(); DefectionDataService = new DefectionDataService(UnitOfWork); DefectionDataService.DefectionAdded += OnDefectionAdded; ColumnHeaders = new List<ColumnInfo> { new ColumnInfo("Code",0), new ColumnInfo("Name",1), new ColumnInfo("Status",2) , new ColumnInfo("Mode",3,true) }; AddCommand = new Command(Add, CanAdd);RefreshCommand = new Command(CreateItems); AddGroupCommand = new Command(Add, CanAddGroup); CreateItems(null); }
private void InitializeData(DefectionDataService dataService) { DefectionDataService = dataService; SaveCommand = new Command(Save, CanSave); }
/// <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> public DefectionVM(Defection entity, AccessType access, DefectionDataService dataService) : base(access) { InitializeData(dataService); _model = entity; }
/// <summary> /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values. /// </summary> public DefectionVM(AccessType access, DefectionDataService dataService):base(access) { InitializeData(dataService); }
public static Defection CreateNew(DefectionDataService dataService) { int id = dataService.AddModel(new Defection { Name = "جدید", Code = string.Empty, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now }); return dataService.GetSingle(id); }
public RootFishbonesVM(RootVM root, ProductDefectionVM productDefection, AccessType access) : base(access) { UnitOfWork = new SoheilEdmContext(); CurrentRoot = root; RootDataService = new RootDataService(UnitOfWork); RootDataService.FishboneAdded += OnFishboneNodeAdded; RootDataService.FishboneRemoved += OnFishboneNodeRemoved; ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork); ProductDataService = new ProductDataService(UnitOfWork); DefectionDataService = new DefectionDataService(UnitOfWork); SwitchItemsCommand = new Command(SetProductDefections); ViewProductDefectionsCommand = new Command(ViewProductDefections); InitializeFishboneCommand = new Command(InitializeFishbone); FishboneNodeDataService = new FishboneNodeDataService(UnitOfWork); RootNode = new FishboneNodeVM(Access, FishboneNodeDataService) { Title = string.Empty, Id = -1, ParentId = -2 }; var selectedVms = new ObservableCollection<FishboneNodeVM>(); foreach (var rootFishboneNode in RootDataService.GetFishboneNodes(root.Id)) { selectedVms.Add(new FishboneNodeVM(rootFishboneNode, Access, FishboneNodeDataService)); } SetProductDefections(); IncludeCommand = new Command(Include, CanInclude); ExcludeTreeCommand = new Command(ExcludeTree, CanExcludeTree); foreach (FishboneNodeVM item in selectedVms) { if (item.ParentId == RootNode.Id) { RootNode.ChildNodes.Add(item); break; } } CurrentNode = RootNode; if (productDefection != null) { foreach (IInfoViewModel item in DefectionList) { if (item.Id == productDefection.DefectionId) { CurrentDefection = item; ViewProductDefections(null); break; } } if(AllItems!=null) foreach (ProductDefectionVM item in AllItems) { if (item.Id == productDefection.Id) { CurrentProductDefection = item; IsEnabled = false; break; } } } }