public IHttpActionResult PutAutist(int id, Autist autist) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != autist.ID) { return(BadRequest()); } db.Entry(autist).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AutistExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetAutist(int id) { Autist autist = db.Autist.Find(id); if (autist == null) { return(NotFound()); } return(Ok(autist)); }
public IHttpActionResult PostAutist(Autist autist) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Autist.Add(autist); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = autist.ID }, autist)); }
public IHttpActionResult DeleteAutist(int id) { Autist autist = db.Autist.Find(id); if (autist == null) { return(NotFound()); } db.Autist.Remove(autist); db.SaveChanges(); return(Ok(autist)); }