public IHttpActionResult Putsubsection(int id, subsection subsection) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != subsection.subsectionID) { return(BadRequest()); } db.Entry(subsection).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!subsectionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Getsubsection(int id) { subsection subsection = db.subsections.Find(id); if (subsection == null) { return(NotFound()); } return(Ok(subsection)); }
public IHttpActionResult Postsubsection(subsection subsection) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.subsections.Add(subsection); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = subsection.subsectionID }, subsection)); }
public IHttpActionResult Deletesubsection(int id) { subsection subsection = db.subsections.Find(id); if (subsection == null) { return(NotFound()); } db.subsections.Remove(subsection); db.SaveChanges(); return(Ok(subsection)); }