public AddRecipeDialogViewModel(IProductServiceModel productServiceModel,
                                        IEnumerable <WorkplanViewModel> workplans)
        {
            _productServiceModel = productServiceModel;
            Workplans            = workplans.ToArray();
            SelectedWorkplan     = Workplans.FirstOrDefault();

            CloseCmd  = new RelayCommand(Close, CanClose);
            CreateCmd = new AsyncCommand(Create, CanCreate, true);
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public async Task Load(RecipeViewModel recipeVm, IReadOnlyCollection <WorkplanViewModel> workplans)
        {
            _isSelfManagedRecipe = false;
            await LoadTypeAndWorkplans(recipeVm.Model, workplans);

            WorkplanViewModel wp = null;

            if ((recipeVm.Model.WorkplanModel?.Id ?? recipeVm.Model.WorkplanId) != 0)
            {
                wp = Workplans.FirstOrDefault(w => w.Id == (recipeVm.Model.WorkplanModel?.Id ?? recipeVm.Model.WorkplanId));
            }
            recipeVm.Workplan = wp;

            EditableObject = recipeVm;
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public async Task Load(long recipeId, IReadOnlyCollection <WorkplanViewModel> workplans)
        {
            _isSelfManagedRecipe = true;

            var recipeModel = await ProductServiceModel.GetRecipe(recipeId);

            await LoadTypeAndWorkplans(recipeModel, workplans);

            WorkplanViewModel wp = null;

            if (recipeModel.WorkplanId != 0)
            {
                wp = Workplans.FirstOrDefault(w => w.Id == recipeModel.WorkplanId);
            }

            EditableObject = new RecipeViewModel(recipeModel)
            {
                Workplan = wp
            };
        }