public async Task<IHttpActionResult> PutArea(short id, Area area) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != area.IdArea) { return BadRequest(); } db.Entry(area).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AreaExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostArea(Area area) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Area.Add(area); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = area.IdArea }, area); }