public async Task<IHttpActionResult> PutService(int id, Service service) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != service.Id) { return BadRequest(); } db.Entry(service).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ServiceExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostService(Service service) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Services.Add(service); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = service.Id }, service); }