Exemple #1
0
 def returnBook(self, cloudDB, userName):
     
     bookReturnList = cloudDB.getAllBookIdListUserBorrowed(userName)
     if len(bookReturnList) == 0:
         print("You don't have any book to return!")
     else:
     
         print("You can return book No:" + str(bookReturnList))
         for bookID in bookReturnList:
             cloudDB.printABookDetail(bookID)
         print("In which way you want to return the book?")
         print("1. Enter ID")
         print("2. Scan QR Code")
         
         option = TakeInput.inputInteger(1,2)
         if option == 1:            
             print("Which book you want to return?")
             bookId = int(input('Please input the book id you want to return:'))
             while ((bookId in bookReturnList) == False):
                 bookId = int(input("Book Id invalid, please re-enter:"))             
         else:
             print("Please place the book Qr Code infront of the web camera..")
             bookId = int(QrCode.scan())
             while ((bookId in bookReturnList) == False):
                 print("Invalid QrCode, please don't return the book you didn't borrow.")
                 return
             
             
         print("You are returning book No." + str(bookId))    
             
         eId = cloudDB.getEid(userName, bookId)               
         EventManager.deleteEvent(eId)
         returnDate = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
         cloudDB.returnBook(eId,returnDate)
         print('Book returned successfully! Thank you!')
     
     return