public IHttpActionResult PutYearTerm(int id, YearTerm yearTerm) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != yearTerm.YearTermId) { return BadRequest(); } db.Entry(yearTerm).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!YearTermExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostYearTerm(YearTerm yearTerm) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.YearTerms.Add(yearTerm); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = yearTerm.YearTermId }, yearTerm); }