public IHttpActionResult PostRecepcao(Recepcao recepcao) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Recepcao.Add(recepcao); try { db.SaveChanges(); } catch (DbUpdateException) { if (RecepcaoExists(recepcao.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = recepcao.Id }, recepcao)); }
public IHttpActionResult PutRecepcao(long id, Recepcao recepcao) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != recepcao.Id) { return(BadRequest()); } db.Entry(recepcao).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RecepcaoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetRecepcao(long id) { Recepcao recepcao = db.Recepcao.Find(id); if (recepcao == null) { return(NotFound()); } return(Ok(recepcao)); }
public IHttpActionResult DeleteRecepcao(long id) { Recepcao recepcao = db.Recepcao.Find(id); if (recepcao == null) { return(NotFound()); } db.Recepcao.Remove(recepcao); db.SaveChanges(); return(Ok(recepcao)); }
public IHttpActionResult GetRecepcao(long safraId, long propriedadeId) { PropriedadeSafra pp = db.PropriedadeSafra.FirstOrDefault(w => w.SafraId == safraId && w.PropriedadeId == propriedadeId); if (pp == null) { return(null); } Recepcao recepcao = pp.Recepcao.FirstOrDefault(); recepcao.PropriedadeSafra = null; return(Ok(recepcao)); }