private async Task LoadTypeAndWorkplans(RecipeModel model, IReadOnlyCollection <WorkplanViewModel> workplans)
        {
            Workplans = workplans;
            NotifyOfPropertyChange(nameof(Workplans));

            var customization = await ProductServiceModel.GetCustomization();

            var typeModel = customization.RecipeTypes.FirstOrDefault(t => t.Name == model.Type);

            if (typeModel == null)
            {
                throw new InvalidOperationException("Recipe type not found");
            }

            Definition = new RecipeDefinitionViewModel(typeModel);
        }
Ejemplo n.º 2
0
        private async Task LoadTypeAndWorkplans(RecipeModel model, IReadOnlyCollection <WorkplanViewModel> workplans)
        {
            if (!workplans.Any(w => w.Id == (model.WorkplanModel?.Id ?? model.WorkplanId)) && model.WorkplanModel is not null)
            {
                Workplans = workplans.Concat(new WorkplanViewModel[] { new WorkplanViewModel(model.WorkplanModel) }).ToList();
            }
            else
            {
                Workplans = workplans;
            }
            NotifyOfPropertyChange(nameof(Workplans));

            var customization = await ProductServiceModel.GetCustomization();

            var typeModel = customization.RecipeTypes.FirstOrDefault(t => t.Name == model.Type);

            if (typeModel == null)
            {
                throw new InvalidOperationException("Recipe type not found");
            }

            Definition = new RecipeDefinitionViewModel(typeModel);
        }