public IHttpActionResult PutGoscie(int id, Goscie goscie) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != goscie.Id) { return(BadRequest()); } db.Entry(goscie).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GoscieExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetGoscie(int id) { Goscie goscie = db.Goscies.Find(id); if (goscie == null) { return(NotFound()); } return(Ok(goscie)); }
public IHttpActionResult PostGoscie(Goscie goscie) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Goscies.Add(goscie); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = goscie.Id }, goscie)); }
public IHttpActionResult DeleteGoscie(int id) { Goscie goscie = db.Goscies.Find(id); if (goscie == null) { return(NotFound()); } db.Goscies.Remove(goscie); db.SaveChanges(); return(Ok(goscie)); }