public IHttpActionResult PostSTH(STH sTH) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.STH.Add(sTH); try { db.SaveChanges(); } catch (DbUpdateException) { if (STHExists(sTH.CodigoSTH)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = sTH.CodigoSTH }, new STHDTO(sTH))); }
public IHttpActionResult PutSTH(string id, STH sTH) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != sTH.CodigoSTH) { return(BadRequest()); } db.Entry(sTH).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!STHExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public STHDTO(STH s) { if (s == null) { return; } CodigoSTH = s.CodigoSTH; SolicitacaoCod = s.SolicitacaoCod; DataAbertura = s.DataAbertura; }
public IHttpActionResult GetSTH(string id) { STH sTH = db.STH.Find(id); if (sTH == null) { return(NotFound()); } return(Ok(new STHDTO(sTH))); }
public IHttpActionResult DeleteSTH(string id) { STH sTH = db.STH.Find(id); if (sTH == null) { return(NotFound()); } STHDTO s = new STHDTO(sTH); db.STH.Remove(sTH); db.SaveChanges(); return(Ok(s)); }