Ejemplo n.º 1
0
 public IActionResult Post([FromBody] Bong newBong)
 {
     using (BurgerContext context = new BurgerContext())
     {
         context.Bongs.Add(newBong);
         context.SaveChanges();
     }
     return(Created("/burger", newBong));
 }
Ejemplo n.º 2
0
 public IActionResult Post([FromBody] Product newProduct)
 {
     using (BurgerContext context = new BurgerContext())
     {
         context.Products.Add(newProduct);
         context.SaveChanges();
     }
     return(Created("/burger", newProduct));
 }
Ejemplo n.º 3
0
 public IActionResult Post([FromBody] Ingredient newIngredient)
 {
     using (BurgerContext context = new BurgerContext())
     {
         context.Ingredients.Add(newIngredient);
         context.SaveChanges();
     }
     return(Created("/burger", newIngredient));
 }
Ejemplo n.º 4
0
 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());
 }
Ejemplo n.º 5
0
 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());
 }