Beispiel #1
0
 static public bool ReturnBookByReader(Book book, Reader reader)
 {
     using (var context = new LibraryDataContext())
     {
         if (book != null && reader != null)
         {
             if (CheckEventForBookAndReader(reader.reader_id, book.book_id))
             {
                 AddEvent(DateTime.Today, false, book.book_id, reader.reader_id);
                 book.quantity += 1;
                 BookService.UpdateBookQuantity(book.book_id, (int)book.quantity);
                 return(true);
             }
         }
         return(false);
     }
 }
Beispiel #2
0
 static public bool BorrowBookForReader(Book book, Reader reader)
 {
     using (var context = new LibraryDataContext())
     {
         if (book != null && reader != null)
         {
             if (book.quantity > 0)
             {
                 AddEvent(DateTime.Today, true, book.book_id, reader.reader_id);
                 book.quantity -= 1;
                 BookService.UpdateBookQuantity(book.book_id, (int)book.quantity);
                 return(true);
             }
         }
     }
     return(false);
 }