public bool Postuser_book(user_book user_book) { bookEntities ctx = new bookEntities(); ctx.user_book.Add(user_book); try { ctx.SaveChanges(); } catch (DbUpdateException) { var like_book = ctx.user_book.Where(x => x.username == user_book.username && x.bookid == user_book.bookid && x.type == user_book.type); if (like_book != null) { return(false); } else { throw; } } return(true); }
public bool Postcomment(comment comment) { bookEntities ctx = new bookEntities(); ctx.comment.Add(comment); ctx.SaveChanges(); return(true); }
public bool SignUp(user user) { user.password = Share.Class1.EncodeBase64(user.password); ctx.user.Add(user); try { ctx.SaveChanges(); } catch (DbUpdateException) { if (userExists(user.username)) { return(false); } else { throw; } } return(true); }
public bool Deletecomment(comment comment) { bookEntities ctx = new bookEntities(); comment c = ctx.comment.Find(comment.commentid); if (c == null) { return(false); } ctx.comment.Remove(c); ctx.SaveChanges(); return(true); }
public bool AddScore(score score) { ctx.score.Add(score); try { ctx.SaveChanges(); } catch (DbUpdateException) { if (scoreExists(score.username)) { return(false); } else { throw; } } return(true); }