public IHttpActionResult PostPrecoAgricola(PrecoAgricola precoAgricola) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PrecoAgricola.Add(precoAgricola); try { db.SaveChanges(); } catch (DbUpdateException) { if (PrecoAgricolaExists(precoAgricola.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = precoAgricola.Id }, precoAgricola)); }
public IHttpActionResult PutPrecoAgricola(long id, PrecoAgricola precoAgricola) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != precoAgricola.Id) { return(BadRequest()); } db.Entry(precoAgricola).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PrecoAgricolaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetPrecoAgricola(long id) { PrecoAgricola precoAgricola = db.PrecoAgricola.Find(id); if (precoAgricola == null) { return(NotFound()); } return(Ok(precoAgricola)); }
public IHttpActionResult DeletePrecoAgricola(long id) { PrecoAgricola precoAgricola = db.PrecoAgricola.Find(id); if (precoAgricola == null) { return(NotFound()); } db.PrecoAgricola.Remove(precoAgricola); db.SaveChanges(); return(Ok(precoAgricola)); }