예제 #1
0
        public IActionResult Create([FromBody] Ingredient ingredient, [FromRoute] int IdRecipe)
        {
            try
            {
                IngredientCore ingredientCore = new IngredientCore(dbContext);

                ingredientCore.Create(ingredient);

                RecipeIngredientCore recipeIngredientCore = new RecipeIngredientCore(dbContext);

                RecipeIngredient NewRecipeIngredient = new RecipeIngredient();

                Ingredient LastIng = ingredientCore.GetLastRegistered();

                NewRecipeIngredient.IdRecipe     = IdRecipe;
                NewRecipeIngredient.IdIngredient = LastIng.Id;

                recipeIngredientCore.Create(NewRecipeIngredient);

                return(Ok("ingredient Added Succesfully"));
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, ex));
            }
        }
예제 #2
0
 public IActionResult GetAll()
 {
     try
     {
         IngredientCore ingredientCore = new IngredientCore(dbContext);
         return(Ok(ingredientCore.GetAll()));
     }
     catch (Exception ex)
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, ex));
     }
 }
예제 #3
0
        public IActionResult Delete([FromRoute] int id)
        {
            try
            {
                IngredientCore ingredientCore = new IngredientCore(dbContext);

                ingredientCore.Delete(id);

                return(Ok("ingredient Word Deleted Succesfully"));
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, ex));
            }
        }