public IHttpActionResult PutBurger(int id, Burger burger)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != burger.BurgerID)
            {
                return BadRequest();
            }

            db.Entry(burger).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BurgerExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public IHttpActionResult PostBurger(Burger burger)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Burgers.Add(burger);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = burger.BurgerID }, burger);
        }
Beispiel #3
0
 public void AddBurgers(Burger f)
 {
     AvailableBurgers.Add(f);
 }