Esempio n. 1
0
        public MaterialViewModel(IMessageBoxService messageBoxService, Material item, IMaterialManager manager, IMaterialGroupManager groupManager, IUnitManager unitManager) : base(messageBoxService, item, manager)
        {
            // do initialization
            try
            {
                if (groupManager == null)
                {
                    throw new ArgumentNullException("groupManager");
                }
                _groupManager = groupManager;
                // populate the list of groups
                this.GroupList = _groupManager.GetList();

                if (unitManager == null)
                {
                    throw new ArgumentNullException("unitManager");
                }
                _unitManager = unitManager;
                // populate the list of units
                this.UnitList = _unitManager.GetList();

                this.DisplayName = "Edit Material: " + this.Item.Name;
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
Esempio n. 2
0
        public ProductViewModel(IMessageBoxService messageBoxService, Product item, IProductManager manager, IProductGroupManager groupManager, IUnitManager unitManager) : base(messageBoxService, item, manager)
        {
            // do initialization
            try
            {
                if (groupManager == null)
                {
                    throw new ArgumentNullException("groupManager");
                }
                _groupManager = groupManager;
                // populate the list of groups
                this.GroupList = _groupManager.GetList();

                if (unitManager == null)
                {
                    throw new ArgumentNullException("unitManager");
                }
                _unitManager = unitManager;
                // populate the list of units
                this.UnitList = _unitManager.GetList();

                _materialGroupManager  = new MaterialGroupManager();
                this.MaterialGroupList = _materialGroupManager.GetList();

                _materialManager           = new MaterialManager();
                this.AvailableMaterialList = _materialManager.GetList();

                // initialize command
                this.SelectMaterialCommand   = new CommandBase <Material>(o => this.ExecuteSelectMaterialCommand(o), o => this.CanExecuteSelectItemCommand(o));
                this.AddRecipeItemCommand    = new CommandBase <Material>(o => this.ExecuteAddRecipeItemCommand(o), o => this.CanExecuteAddRecipeItemCommand(o));
                this.RemoveRecipeItemCommand = new CommandBase <RecipeItem>(o => this.ExecuteRemoveRecipeItemCommand(o), o => this.CanExecuteRemoveRecipeItemCommand(o));

                this.MarkDeletedCommand = new CommandBase <RecipeItem>(o => this.Item.Delete(), o => !this.Item.IsDeleted);

                this.DisplayName = "Edit Product: " + this.Item.Name;
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }