public IHttpActionResult PostTag(Tag tag) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Tags.Add(tag); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tag.ID }, tag)); }
public IHttpActionResult PostUser(User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Users.Add(user); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = user.ID }, user)); }
public IHttpActionResult Remove(int id) { Chapter chapter = db.Chapters.Find(id); if (chapter == null) { return(NotFound()); } db.Chapters.Remove(chapter); db.SaveChanges(); return(Ok(HttpStatusCode.OK)); }
public IHttpActionResult DeleteAuthor(int id) { Author author = db.Authors.Find(id); if (author == null) { return(NotFound()); } db.Authors.Remove(author); db.SaveChanges(); return(Ok(author)); }
public IHttpActionResult Remove(int id) { Voice voice = db.Voices.Find(id); if (voice == null) { return(NotFound()); } try { db.Voices.Remove(voice); db.SaveChanges(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok(HttpStatusCode.OK)); }
public IHttpActionResult Remove(int id) { Application application = db.Applications.Find(id); if (application == null) { return(NotFound()); } try { db.Applications.Remove(application); db.SaveChanges(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok(HttpStatusCode.OK)); }