Exemple #1
0
        /// <summary>
        /// Method to delete a cooking instruction from the database
        /// </summary>
        /// <param name="instruction"></param>
        /// <returns></returns>
        public async Task DeleteCookingInstructionAsync(ComboBox instruction)
        {
            var isValid = ValidationObject.ValidateInstructionSelection(instruction);

            if (isValid)
            {
                var instructionToDelete = instruction.SelectedItem as CookingInstructionDTO;
                var deleted             = await BusinessObject.DeleteCookingInstructionAsync(instructionToDelete);

                if (deleted)
                {
                    ShowMessage($"Cooking Instruction {instructionToDelete.Name} Deleted Successfully");
                }
                else
                {
                    ShowMessage($"Cooking Instruction {instructionToDelete.Name} Not Deleted");
                }
            }
        }
Exemple #2
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} ");
                }
            }
        }