public async Task<IHttpActionResult> PutCommonCode(int id, CommonCode commonCode) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != commonCode.CodeNo) { return BadRequest(); } db.Entry(commonCode).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommonCodeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostCommonCode(CommonCode commonCode) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.CommonCodes.Add(commonCode); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = commonCode.CodeNo }, commonCode); }