public IActionResult Post([FromBody] Bong newBong) { using (BurgerContext context = new BurgerContext()) { context.Bongs.Add(newBong); context.SaveChanges(); } return(Created("/burger", newBong)); }
public IActionResult Post([FromBody] Product newProduct) { using (BurgerContext context = new BurgerContext()) { context.Products.Add(newProduct); context.SaveChanges(); } return(Created("/burger", newProduct)); }
public IActionResult Post([FromBody] Ingredient newIngredient) { using (BurgerContext context = new BurgerContext()) { context.Ingredients.Add(newIngredient); context.SaveChanges(); } return(Created("/burger", newIngredient)); }
public IActionResult Delete(int id) { using (BurgerContext context = new BurgerContext()) { Product toRemove = context.Products.First(p => p.Id == id); context.Products.Remove(toRemove); context.SaveChanges(); } return(Ok()); }
public IActionResult Put(int id, [FromBody] Product p) { using (BurgerContext context = new BurgerContext()) { Product toUpdate = context.Products.First(p => p.Id == id); toUpdate.Price = p.Price; toUpdate.Burger = p.Burger; context.SaveChanges(); } return(Ok()); }