public async Task<IHttpActionResult> PostFondo(Fondo fondo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Fondos.Add(fondo); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (FondoExists(fondo.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = fondo.Id }, fondo); }
public async Task<IHttpActionResult> PutFondo(int id, Fondo fondo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != fondo.Id) { return BadRequest(); } db.Entry(fondo).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FondoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }