示例#1
0
        /// <summary>
        /// Method to add a cooking instruction to a recipe
        /// </summary>
        /// <param name="recipe">The recipe to add the cooking instruction to </param>
        /// <param name="instruction">The instruction to add to the recipe</param>
        public async Task AddCookingInstructionToRecipe(ComboBox recipe, ComboBox instruction)
        {
            var isRecipeValid      = recipeUI.ValidationObject.ValidateRecipeSelection(recipe);
            var isInstructionValid = ValidationObject.ValidateInstructionSelection(instruction);

            if (isRecipeValid && isInstructionValid)
            {
                var recipeToAddInstruction   = recipe.SelectedItem as RecipeDTO;
                var instructionToAddToRecipe = instruction.SelectedItem as CookingInstructionDTO;
                var added = await BusinessObject.AddCookingInstructionToRecipeAsync(recipeToAddInstruction, instructionToAddToRecipe);

                if (added)
                {
                    ShowMessage($"Cooking Instruction {instructionToAddToRecipe.Name} Added To Recipe {recipeToAddInstruction.Name} ");
                }
                else
                {
                    ShowMessage($"Cooking Instruction {instructionToAddToRecipe.Name} Not Added To Recipe {recipeToAddInstruction.Name} ");
                }
            }
        }