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 { RecipeIngredientCore recipeIngredientCore = new RecipeIngredientCore(dbContext); return(Ok(recipeIngredientCore.GetAll())); } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex)); } }
public IActionResult Create([FromBody] RecipeIngredient recipeIngredient) { try { RecipeIngredientCore recipeIngredientCore = new RecipeIngredientCore(dbContext); recipeIngredientCore.Create(recipeIngredient); return(Ok("recipeIngredient Word Added Succesfully")); } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex)); } }