public IHttpActionResult PostClasses(Classes classes) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Classes.Add(classes); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = classes.Id }, classes); }
public IHttpActionResult PutClasses(int id, Classes classes) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != classes.Id) { return BadRequest(); } db.Entry(classes).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ClassesExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }