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)); } }
public IActionResult GetAll() { try { IngredientCore ingredientCore = new IngredientCore(dbContext); return(Ok(ingredientCore.GetAll())); } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex)); } }
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)); } }