public async Task<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 { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostProject(Project project) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Project.Add(project); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = project.Id }, project); }