public IHttpActionResult PutDeget(int id, Deget deget) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != deget.Id) { return(BadRequest()); } db.Entry(deget).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DegetExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetDeget(int id) { Deget deget = db.Degets.Find(id); if (deget == null) { return(NotFound()); } return(Ok(deget)); }
public IHttpActionResult PostDeget(Deget deget) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Degets.Add(deget); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = deget.Id }, deget)); }
public IHttpActionResult DeleteDeget(int id) { Deget deget = db.Degets.Find(id); if (deget == null) { return(NotFound()); } db.Degets.Remove(deget); db.SaveChanges(); return(Ok(deget)); }