public IHttpActionResult PutArticulo(int id, Articulo articulo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != articulo.Id) { return BadRequest(); } db.Entry(articulo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ArticuloExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostArticulo(Articulo articulo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Articulos.Add(articulo); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = articulo.Id }, articulo); }