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); }
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); }