public IHttpActionResult Postcntros(cntros cntros) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.cntros.Add(cntros); try { db.SaveChanges(); } catch (DbUpdateException) { if (cntrosExists(cntros.cntros_cdgo)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = cntros.cntros_cdgo }, cntros)); }
public IHttpActionResult Putcntros(string id, cntros cntros) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cntros.cntros_cdgo) { return(BadRequest()); } db.Entry(cntros).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!cntrosExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Getcntros(string id) { cntros cntros = db.cntros.Find(id); if (cntros == null) { return(NotFound()); } return(Ok(cntros)); }
public IHttpActionResult Deletecntros(string id) { cntros cntros = db.cntros.Find(id); if (cntros == null) { return(NotFound()); } db.cntros.Remove(cntros); db.SaveChanges(); return(Ok(cntros)); }