public IHttpActionResult PosttbEstudante(tbEstudante tbEstudante) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tbEstudante.Add(tbEstudante); try { db.SaveChanges(); } catch (DbUpdateException) { if (tbEstudanteExists(tbEstudante.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = tbEstudante.Id }, tbEstudante)); }
public IHttpActionResult PuttbEstudante(int id, tbEstudante tbEstudante) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbEstudante.Id) { return(BadRequest()); } db.Entry(tbEstudante).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tbEstudanteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GettbEstudante(int id) { tbEstudante tbEstudante = db.tbEstudante.Find(id); if (tbEstudante == null) { return(NotFound()); } return(Ok(tbEstudante)); }
public IHttpActionResult DeletetbEstudante(int id) { tbEstudante tbEstudante = db.tbEstudante.Find(id); if (tbEstudante == null) { return(NotFound()); } db.tbEstudante.Remove(tbEstudante); db.SaveChanges(); return(Ok(tbEstudante)); }