Esempio n. 1
0
        public IActionResult Get(string name)
        {
            var recipe = RecipeData.getRecipeData(name);

            if (recipe == null)
            {
                return(NotFound("No recipe found."));
            }
            return(Ok(recipe));
        }
Esempio n. 2
0
        public IActionResult SaveRecipe(Recipe recipe)
        {
            var _recipes = RecipeData.getRecipeData();

            if (RecipeData.noDuplicated(_recipes, recipe) == false)
            {
                return(NotFound("Recipe already exists"));
            }
            _recipes.Add(recipe);
            if (_recipes.Count == 0)
            {
                return(NotFound("No List Found."));
            }
            RecipeData.writeData(_recipes);
            return(Ok(_recipes));
        }
Esempio n. 3
0
        public IActionResult DeleteRecipe(string name)
        {
            var recipe = RecipeData.getRecipeData(name);

            if (recipe == null)
            {
                return(NotFound("No recipe found."));
            }
            var _recipes = RecipeData.deleteData(name);

            if (_recipes.Count == 0)
            {
                return(NotFound("No list found"));
            }
            RecipeData.writeData(_recipes);
            return(Ok(_recipes));
        }
Esempio n. 4
0
        public IActionResult Gets()
        {
            var _recipes = RecipeData.getRecipeData();

            return(Ok(_recipes));
        }