public async Task<IHttpActionResult> PutService(string id, Service service) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != service.Id) { return BadRequest(); } db.Entry(service).State = System.Data.Entity.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); }