public IHttpActionResult Postcartera(cartera cartera) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.cartera.Add(cartera); try { db.SaveChanges(); } catch (DbUpdateException) { if (carteraExists(cartera.idcartera)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = cartera.idcartera }, cartera)); }
public IHttpActionResult Putcartera(int id, cartera cartera) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cartera.idcartera) { return(BadRequest()); } db.Entry(cartera).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!carteraExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Getcartera(int id) { cartera cartera = db.cartera.Find(id); if (cartera == null) { return(NotFound()); } return(Ok(cartera)); }
public IHttpActionResult Deletecartera(int id) { cartera cartera = db.cartera.Find(id); if (cartera == null) { return(NotFound()); } db.cartera.Remove(cartera); db.SaveChanges(); return(Ok(cartera)); }