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(); ProductGroupDataService = new ProductGroupDataService(UnitOfWork); ProductDataService = new ProductDataService(UnitOfWork); ProductDataService.ProductAdded += OnProductAdded; ProductGroupDataService.ProductGroupAdded += OnProductGroupAdded; ColumnHeaders = new List<ColumnInfo> { new ColumnInfo("Code",0), new ColumnInfo("Name",1), new ColumnInfo("Color",3), new ColumnInfo("Status",2) , new ColumnInfo("Mode",4,true) }; AddCommand = new Command(Add, CanAdd);RefreshCommand = new Command(CreateItems); AddGroupCommand = new Command(AddGroup); ViewCommand = new Command(View, CanView); CreateItems(null); }
private void InitializeData(ProductGroupDataService dataService) { ProductGroupDataService = dataService; SaveCommand = new Command(Save, CanSave); }
/// <summary> /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values. /// </summary> public ProductGroupVM(AccessType access, ProductGroupDataService dataService):base(access) { InitializeData(dataService); }
/// <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 ProductGroupVM(ProductGroup entity, AccessType access, ProductGroupDataService dataService):base(access) { InitializeData(dataService); _model = entity; }
public static ProductGroup CreateNew(ProductGroupDataService dataService) { int id = dataService.AddModel(new ProductGroup { Name = "گروه جدید", Code = string.Empty, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now }); return dataService.GetSingle(id); }
private void InitializeData() { UnitOfWork = new SoheilEdmContext(); FpcDataService = new FPCDataService(); ProductDataService = new ProductDataService(UnitOfWork); ProductGroupDataService = new ProductGroupDataService(UnitOfWork); FpcDataService.FpcAdded += OnFpcAdded; 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, () => false); CreateItems(null); }
/// <summary> /// Creates a UOW and initializes DataServices and adds ProductGroups and stuff /// </summary> private void InitializeData() { var uow = new Dal.SoheilEdmContext(); ProductGroupDataService = new ProductGroupDataService(uow); ProductDataService = new ProductDataService(uow); //Create Tree //add general node first var general = new GeneralVm(); general.Selected += SelectNode; Tree.Add(general); //add all groups and their children recursively var allGroups = ProductGroupDataService.GetActives(); foreach (var productGroup in allGroups) { var pg = new ProductGroupVm(productGroup); pg.Selected += SelectNode; Tree.Add(pg); } IsLoading = false; }
/// <summary> /// Initializes a new instance of the <see cref="ProductVM"/> class. /// </summary> /// <param name="entity">The entity.</param> /// <param name="access"></param> /// <param name="dataService"></param> /// <param name="groupDataService"></param> public ProductVM(Product entity, AccessType access, ProductDataService dataService, ProductGroupDataService groupDataService) : base(access) { _model = entity; InitializeData(dataService, groupDataService); Groups = new ListCollectionView(new ObservableCollection<ProductGroupVM>()); }
/// <summary> /// Initializes a new instance of the <see cref="ProductVM"/> class from the model. /// </summary> /// <param name="entity">The model.</param> /// <param name="groupItems">The group view models.</param> /// <param name="access"></param> /// <param name="dataService"></param> /// <param name="groupDataService"></param> public ProductVM(Product entity, ListCollectionView groupItems, AccessType access, ProductDataService dataService, ProductGroupDataService groupDataService) : base(access) { InitializeData(dataService, groupDataService); _model = entity; Groups = groupItems; foreach (ProductGroupVM groupVm in groupItems) { if (groupVm.Id == entity.ProductGroup.Id) { SelectedGroupVM = groupVm; break; } } }