// PUT api/Week/5 public IHttpActionResult PutWeek(int id, Week week) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != week.Id) { return BadRequest(); } db.Entry(week).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!WeekExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostWeek(Week week) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Week.Add(week); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = week.Id }, week); }