Exemplo n.º 1
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.º 2
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);
        }
Exemplo n.º 3
0
        protected async Task AddIngredientAsync()
        {
            Console.Write("\n    Enter name ingredient: ");
            string name = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            await _ingredientsController.AddAsync(name);
        }
Exemplo n.º 4
0
        private async Task OpenRecipeAync(int recipeId)
        {
            Console.Clear();
            Recipe recipe = await _recipesController.GetRecipeByIdAsync(recipeId);

            Console.WriteLine($"{new string('\n', 5)}    ________{recipe.Name}________\n\n");
            Console.WriteLine($"    { await ValidationNavigation.WrapTextAsync(10, recipe.Description, "\n    ")}");
            Console.WriteLine("\n    Required ingredients:\n");
            List <string> ingredients = await _recipesController.GetIngredientsWhereRecipeIdAsync(recipeId);

            //ingredients recipe
            foreach (string ingredient in ingredients)
            {
                Console.WriteLine($"    {ingredient}");
            }
            //steps recipe
            Console.WriteLine("\n    Сooking steps:\n");
            List <CookingStep> cookingSteps = await _recipesController.GetCookingStepsWhereRecipeIdAsync(recipeId);

            foreach (CookingStep cookingStep in cookingSteps.OrderBy(x => x.Step))
            {
                Console.WriteLine($"    {cookingStep.Step}. {await ValidationNavigation.WrapTextAsync(10, cookingStep.Name, "\n       ")}");
            }
            Console.WriteLine("\n    Press any key to return...");
            Console.ReadKey();
        }
        private async Task RenameAsync()
        {
            Console.Write("    Enter new name: ");
            string newName = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine());

            await _ingredientsController.RenameAsync(_ingredientId, newName);
        }
 private async Task DeleteAsync()
 {
     Console.WriteLine("    Do you really want to remove the ingredient? ");
     if ((await ValidationNavigation.ShowYesNoAsync()) == ConsoleKey.N)
     {
         return;
     }
     await _ingredientsController.DeleteAsync(_ingredientId);
 }
 private async Task DeleteAsync()
 {
     Console.Write("    Attention! Are you sure you want to delete the category? You will also delete all the recipes that are in them! ");
     if ((await ValidationNavigation.ShowYesNoAsync()) == ConsoleKey.N)
     {
         return;
     }
     await _categoriesController.DeleteAsync(_categoryId);
 }
Exemplo n.º 8
0
 private async Task DeleteAsync(int cookingStepId)
 {
     Console.WriteLine("\n    Do you really want to remove the cooking step? ");
     if (await ValidationNavigation.ShowYesNoAsync() == ConsoleKey.N)
     {
         return;
     }
     await _cookingStepsController.DeleteAsync(cookingStepId);
 }
Exemplo n.º 9
0
 private async Task DeleteRecipeAsync(int recipeId)
 {
     Console.Clear();
     Console.WriteLine("\n    Are you sure you want to delete the recipe? ");
     if (await ValidationNavigation.ShowYesNoAsync() == ConsoleKey.N)
     {
         return;
     }
     await _recipesController.DeleteAsync(recipeId);
 }
Exemplo n.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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();
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Get the ingredients of the specified batch
        /// </summary>
        /// <param name="itemsMenu"></param>
        /// <param name="idBatch"></param>
        protected async Task <List <EntityMenu> > GetIngredientsBatchAsync(List <EntityMenu> itemsMenu, int idBatch = 1)
        {
            try
            {
                List <IEnumerable <Ingredient> > ingredientsBatch = await _ingredientsController.GetIngredientsBatchAsync();

                int countBatch = ingredientsBatch.Count;
                if (idBatch > ingredientsBatch.Count || idBatch < 0)
                {
                    _pageIngredients = await ValidationNavigation.BatchExistAsync(idBatch, countBatch);

                    idBatch = _pageIngredients;
                }
                idBatch--;
                IEnumerable <Ingredient> ingredients = ingredientsBatch.ElementAt(idBatch);
                foreach (Ingredient batch in ingredients)
                {
                    if (itemsMenu != null)
                    {
                        itemsMenu.Add(new EntityMenu()
                        {
                            Id = batch.Id, Name = $"    {batch.Name}", TypeEntity = "ingr"
                        });
                    }
                }
                idBatch++;
                itemsMenu = itemsMenu
                            .Select(i => i.TypeEntity == "pages"
                ? new EntityMenu {
                    Name = $"    Go to page. Pages: {idBatch}/{countBatch}", TypeEntity = "pages"
                }
                : i).ToList();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("    Press any key...");
                Console.ReadKey();
            }
            return(itemsMenu);
        }