public IHttpActionResult GetOlaLeafManuscript(int id) { OlaLeafManuscript olaLeafManuscript = db.OlaLeafManuscripts.Find(id); if (olaLeafManuscript == null) { return(NotFound()); } return(Ok(olaLeafManuscript)); }
public IHttpActionResult PostOlaLeafManuscript(OlaLeafManuscript olaLeafManuscript) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.OlaLeafManuscripts.Add(olaLeafManuscript); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = olaLeafManuscript.Id }, olaLeafManuscript)); }
public IHttpActionResult DeleteOlaLeafManuscript(int id) { OlaLeafManuscript olaLeafManuscript = db.OlaLeafManuscripts.Find(id); if (olaLeafManuscript == null) { return(NotFound()); } db.OlaLeafManuscripts.Remove(olaLeafManuscript); db.SaveChanges(); return(Ok(olaLeafManuscript)); }
public IHttpActionResult PutOlaLeafManuscript(int id, OlaLeafManuscript olaLeafManuscript) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != olaLeafManuscript.Id) { return(BadRequest()); } // Check if the user is allowed to change items' availabilities. if ((!User.IsInRole("Administrator")) && (olaLeafManuscript.Availability != db.OlaLeafManuscripts.AsNoTracking().Where(o => o.Id == id).Select(o => o.Availability).Single())) { return(BadRequest("You don't have permission to change the item's availability.")); } db.Entry(olaLeafManuscript).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OlaLeafManuscriptExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }