public IHttpActionResult PutProject(int id, Project project) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != project.Id) { return BadRequest(); } db.Entry(project).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostProject(Project project) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Projects.Add(project); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = project.Id }, project); }