Exemplo n.º 1
0
        private async Task ChangeDescRecipe(int recipeId)
        {
            Console.Write("\n    Enter recipe description: ");
            string desc = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            await _recipesController.ChangeDescription(recipeId, desc);
        }
        private async Task RenameAsync()
        {
            Console.Write("    Enter new name: ");
            string newName = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            await _ingredientsController.RenameAsync(_ingredientId, newName);
        }
Exemplo n.º 3
0
        private async Task RenameRecipeAsync(int recipeId)
        {
            Console.Write("\n    Enter the name of the recipe: ");
            string newName = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            await _recipesController.RenameAsync(recipeId, newName);
        }
Exemplo n.º 4
0
        protected async Task AddIngredientAsync()
        {
            Console.Write("\n    Enter name ingredient: ");
            string name = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            await _ingredientsController.AddAsync(name);
        }
Exemplo n.º 5
0
        private async Task EditAsync(int cookingStepId)
        {
            CookingStep cookingStep = await _cookingStepsController.GetCookingStepByIdAsync(cookingStepId);

            Console.WriteLine($"\n    Describe the cooking step {cookingStep.Step}: ");
            string stepName = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            cookingStep.Name = stepName;
            await _cookingStepsController.EditAsync(cookingStep);
        }
Exemplo n.º 6
0
        private async Task AddCategoryAsync()
        {
            Console.Write("\n    Enter name category: ");
            string name = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            Console.Write("    Enter name main category: ");
            string parentСategoryName = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            await _categoriesController.AddAsync(name, parentСategoryName);

            await ShowMenuAsync();
        }
Exemplo n.º 7
0
        private async Task AddRecipeAsync()
        {
            Console.WriteLine($"\n    The recipe will be added to the category: {(await _recipesController.GetCategoryByIdAsync(_currentCategoryId)).Name}");
            Console.Write("\n    Enter the name of the recipe: ");
            string nameRecipe = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            Console.Write("\n    Enter recipe description: ");
            string description = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            await _recipesController.AddAsync(nameRecipe, description, _currentCategoryId);

            await ShowMenuAsync();
        }
Exemplo n.º 8
0
        private async Task AddAsync(int recipeId)
        {
            int currentStep = (await _cookingStepsController.GetCookingStepsWhereRecipeIdAsync(recipeId)).Any() ?
                              (await _cookingStepsController.GetCookingStepsWhereRecipeIdAsync(recipeId)).Max(x => x.Step) + 1 : 1;

            Console.WriteLine($"\n    Describe the cooking step {currentStep}: ");
            string stepName = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            await _cookingStepsController.AddAsync(recipeId, currentStep, stepName);

            Console.WriteLine("\n    Add another cooking step? ");
            if (await ValidationNavigation.ShowYesNoAsync() == ConsoleKey.N)
            {
                return;
            }
            await AddAsync(recipeId);
        }
Exemplo n.º 9
0
        private async Task AddAsync(int recipeId, int ingredientId)
        {
            try
            {
                Console.Write("\n    Enter the amount of ingredient: ");
                double amount = double.Parse(Console.ReadLine().Replace(".", ","));
                Console.Write("    Enter the unit of ingredient: ");
                string unit = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

                await _amountRecipeIngredientsController.AddAsync(amount, unit, recipeId, ingredientId);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.WriteLine("\n    Press any key...");
                Console.ReadKey();
            }
        }