Example #1
0
 public static void deleteBook(string ISBN)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         db.Books.Remove(db.Books.Where(b => b.ISBN == ISBN).FirstOrDefault());
         db.SaveChanges();
     }
 }
Example #2
0
 public static void deleteAuthor(int id)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         db.Authors.Remove(db.Authors.Where(g => g.id == id).FirstOrDefault());
         db.SaveChanges();
     }
 }
Example #3
0
 public static void addGenre(Genre g)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         db.Genres.Add(g);
         db.SaveChanges();
     }
 }
Example #4
0
 public static void addBook(Book b)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         db.Books.Add(b);
         db.SaveChanges();
     }
 }
Example #5
0
 public static void addAuthor(Author a)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         db.Authors.Add(a);
         db.SaveChanges();
     }
 }
Example #6
0
 public static void addReview(Review r)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         db.Reviews.Add(r);
         db.SaveChanges();
     }
 }
Example #7
0
 public static void dislikeReview(int reviewId, string userName)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         db.Reviews.Where(b => b.id == reviewId).FirstOrDefault().UsersLikes.
         Remove(db.AspNetUsers.Where(u => u.UserName == userName).FirstOrDefault());
         db.SaveChanges();
     }
 }
Example #8
0
 public static void dislikeBook(string ISBN, string userName)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         db.Books.Where(b => b.ISBN == ISBN).FirstOrDefault().aspnet_UsersLikes.
         Remove(db.AspNetUsers.Where(u => u.UserName == userName).FirstOrDefault());
         db.SaveChanges();
     }
 }
Example #9
0
 public static void updateAuthor(Author author)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         var oldAuthor = db.Authors.Where(a => a.id == author.id).FirstOrDefault();
         oldAuthor.Name        = author.Name;
         oldAuthor.description = author.description;
         db.SaveChanges();
     }
 }
Example #10
0
 public static void updateGenre(Genre genre)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         var oldGenre = db.Genres.Where(g => g.id == genre.id).FirstOrDefault();
         oldGenre.Name        = genre.Name;
         oldGenre.description = genre.description;
         db.SaveChanges();
     }
 }
Example #11
0
        public static bool ReviewIsLiked(int reviewId, string userName)
        {
            bool liked = false;

            using (BookClub_Entities db = new BookClub_Entities())
            {
                if (db.Reviews.Where(b => b.id == reviewId).FirstOrDefault().UsersLikes
                    .FirstOrDefault(u => u.UserName == userName) != null)
                {
                    liked = true;
                }
                db.SaveChanges();
            }
            return(liked);
        }
Example #12
0
        public static bool bookIsLiked(string ISBN, string userName)
        {
            bool liked = false;

            using (BookClub_Entities db = new BookClub_Entities())
            {
                if (db.Books.Where(b => b.ISBN == ISBN).FirstOrDefault().aspnet_UsersLikes
                    .FirstOrDefault(u => u.UserName == userName) != null)
                {
                    liked = true;
                }
                db.SaveChanges();
            }
            return(liked);
        }
Example #13
0
 public static void updateBook(Book book)
 {
     using (BookClub_Entities db = new BookClub_Entities())
     {
         var oldBook = db.Books.Where(b => b.ISBN == book.ISBN).FirstOrDefault();
         if (oldBook != null)
         {
             oldBook.title       = book.title;
             oldBook.image       = book.image;
             oldBook.genreId     = book.genreId;
             oldBook.authorId    = book.authorId;
             oldBook.description = book.description;
             oldBook.date        = book.date;
             db.SaveChanges();
         }
     }
 }