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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 private void InitializeData(ProductGroupDataService dataService)
 {
     ProductGroupDataService = dataService;
     SaveCommand = new Command(Save, CanSave);
 }
Exemple #4
0
 /// <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);
 }
Exemple #5
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>
 public ProductGroupVM(ProductGroup entity, AccessType access, ProductGroupDataService dataService):base(access)
 {
     InitializeData(dataService);
     _model = entity;
 }
Exemple #6
0
 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);
 }
Exemple #7
0
        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);
        }
Exemple #8
0
		/// <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;
		}
Exemple #9
0
 /// <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>());
 }
Exemple #10
0
 /// <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;
         }
     }
 }