public IHttpActionResult PostServicesView(ServicesView servicesView) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.ServicesViews.Add(servicesView); try { db.SaveChanges(); } catch (DbUpdateException) { if (ServicesViewExists(servicesView.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = servicesView.Id }, servicesView); }
public IHttpActionResult PutServicesView(int id, ServicesView servicesView) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != servicesView.Id) { return BadRequest(); } db.Entry(servicesView).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ServicesViewExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }