public async Task<IHttpActionResult> PostMobileData(MobileData mobileData) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.MobileDatas.Add(mobileData); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (MobileDataExists(mobileData.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = mobileData.Id }, mobileData); }
public async Task<IHttpActionResult> PutMobileData(Guid id, MobileData mobileData) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != mobileData.Id) { return BadRequest(); } db.Entry(mobileData).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MobileDataExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }