Esempio n. 1
0
        public async Task NewRecipeAsync()
        {
            if (SelectedRecipeGroup == null)
            {
                //__prompt user to select destination Group
                IEnumerable <string>    groupNames    = CurrentRecipeGroups.Select(g => g.Name);
                SelectTargetGroupDialog groupSelector = new SelectTargetGroupDialog(groupNames);
                await groupSelector.ShowAsync();

                string groupName = groupSelector.SelectedGroupName;
                SelectedRecipeGroup = CurrentRecipeGroups.FirstOrDefault(g => g.Name == groupName);
            }
            if (SelectedRecipeGroup.Recipes is null)
            {
                SelectedRecipeGroup.Recipes = new ObservableCollection <Recipe>();
            }

            NewNamedItemDialog dialog = new NewNamedItemDialog("Enter Recipe Name");
            var result = await dialog.ShowAsync();

            //__quit quietly if dialog was cancelled
            if (dialog.WasCancelled)
            {
                return;
            }

            //__create new Recipe with entered Name
            Recipe newRecipe = new Recipe(dialog.TextEntry);

            SelectedRecipeGroup.Recipes.Add(newRecipe);
            SelectedRecipe = newRecipe;
            await SaveRecipeBoxAsync();

            GoToRecipeDetail();
        }
Esempio n. 2
0
        public async Task NewRecipeGroupAsync()
        {
            NewNamedItemDialog dialog = new NewNamedItemDialog("Enter Group Name");
            var result = await dialog.ShowAsync();

            RecipeGroup newGroup = new RecipeGroup(dialog.TextEntry);

            CurrentRecipeGroups.Add(newGroup);
            RaisePropertyChanged(nameof(CurrentRecipeGroups));
        }