// PUT api/DailyLunch/5 public async Task<IHttpActionResult> PutDailyLunch(int id, DailyLunch dailylunch) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != dailylunch.ID) { return BadRequest(); } db.Entry(dailylunch).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DailyLunchExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostDailyLunch(DailyLunch dailylunch) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.DailyLunches.Add(dailylunch); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = dailylunch.ID }, dailylunch); }