public IHttpActionResult PostMOBILE(MOBILE mobile) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.MOBILE.Add(mobile); try { db.SaveChanges(); } catch (DbUpdateException) { if (MOBILEExists(mobile.id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = mobile.id }, mobile); }
// PUT api/Mobile/5 public IHttpActionResult PutMOBILE(string id, MOBILE mobile) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != mobile.id) { return BadRequest(); } db.Entry(mobile).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MOBILEExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }