예제 #1
0
 def addClient(self):
     #asks the user for data regarding the client and calls the add function from services
     clientId = input("Client ID: ")
     clientName = input("Client Name: ")
     self._validateinteger.validate_integer(clientId)
     self._srv.add_client(clientId, clientName, True)
     RedoManager.delete()
예제 #2
0
def remove_book_undo_handler(srv, bookId, bookTitle, bookAuthor, rlist):
    RedoManager.register_operation(srv, RedoHandler.ADD_BOOK, bookId,
                                   bookTitle, bookAuthor, rlist)
    srv.add_book(int(bookId), bookTitle, bookAuthor, False)
    for rent in rlist:
        srv.add_rental(rent.rentalID, rent.book.bookID, rent.client.clientID,
                       rent.rentedDate, rent.returnedDate, False)
예제 #3
0
def add_book_undo_handler(srv, bookId, bookTitle, bookAuthor):
    #print(bookId)
    #print(bookTitle)
    #print(bookAuthor)
    RedoManager.register_operation(srv, RedoHandler.REMOVE_BOOK, bookId,
                                   bookTitle, bookAuthor)
    #srv._booksList.remove
    srv.remove_book(bookId, False)
예제 #4
0
 def updateClient(self):
     #updates a given client by its ID
     #asks the user for the id of the client he wants to modify and for the new data
     clientId = input("Client ID: ")
     self._validateinteger.validate_integer(clientId)
     clientName = input("New client Name: ")
     self._srv.update_client(clientId, clientName, True)
     RedoManager.delete()
예제 #5
0
def update_client_undo_handler(srv, clientId, name):
    clients = srv.list_clients()
    for client in clients:
        if client.clientID == int(clientId):
            RedoManager.register_operation(srv, RedoHandler.UPDATE_CLIENT,
                                           client.clientID, client.clientName)
            break
    srv.update_client(clientId, name, False)
예제 #6
0
 def addBook(self):
     #asks the user for data regarding the book and calls the add function from services
     bookId = input("Book ID: ")
     bookTitle = input("Book Title: ")
     bookAuthor = input("Book Author: ")
     self._validateinteger.validate_integer(bookId)
     bookId = int(bookId)
     self._srv.add_book(bookId, bookTitle, bookAuthor, True)
     RedoManager.delete()
예제 #7
0
def remove_client_undo_handler(srv, clientId, name, rlist):
    RedoManager.register_operation(srv, RedoHandler.ADD_CLIENT, clientId, name,
                                   rlist)
    #print(len(rlist))
    #srv._clientsList.add(Client(clientId, name))
    srv.add_client(int(clientId), name, False)
    for rent in rlist:
        srv.add_rental(rent.rentalID, rent.book.bookID, rent.client.clientID,
                       rent.rentedDate, rent.returnedDate, False)
예제 #8
0
 def updateBook(self):
     #updates a given book by its ID
     #asks the user for the id of the book he wants to modify and for the new data
     bookId = input("Book ID: ")
     self._validateinteger.validate_integer(bookId)
     bookTitle = input("New book Title: ")
     bookAuthor = input("New book Author: ")
     self._srv.update_book(bookId, bookTitle, bookAuthor, True)
     RedoManager.delete()
예제 #9
0
def update_rental_undo_handler(srv, rentalId, bookId, clientId, rentedDate,
                               returnedDate):
    rentals = srv._repoRental.get_all()
    for rent in rentals:
        if rent.rentalID == rentalId:
            RedoManager.register_operation(srv, RedoHandler.UPDATE_RENTAL,
                                           rentalId, bookId, clientId,
                                           rentedDate, rent.returnedDate)
            break
    srv.update_rental(rentalId, returnedDate, False)
예제 #10
0
 def rentBook(self):
     rentalId = input("Enter rental ID: ")
     bookId = input("Enter book ID: ")
     clientId = input("Enter client ID: ")
     self._validateinteger.validate_integer(bookId)
     self._validateinteger.validate_integer(clientId)
     self._validateinteger.validate_integer(rentalId)
     rentedDate = datetime.date.today()
     self._srv.add_rental(rentalId, bookId, clientId, rentedDate, None,
                          True)
     RedoManager.delete()
예제 #11
0
def update_book_undo_handler(srv, bookId, bookTitle, bookAuthor):
    #print(int(bookId))
    #print(bookTitle)
    #print(bookAuthor)
    blist = srv.list_books()
    for book in blist:
        if book.bookID == int(bookId):
            RedoManager.register_operation(srv, RedoHandler.UPDATE_BOOK,
                                           book.bookID, book.bookTitle,
                                           book.bookAuthor)
            break
    srv.update_book(bookId, bookTitle, bookAuthor, False)
예제 #12
0
 def returnBook(self):
     rentalId = input("Enter rental ID: ")
     self._validateinteger.validate_integer(rentalId)
     print("Enter returned date... ")
     returned_day = input("Enter returned day: ")
     returned_month = input("Enter returned month: ")
     returned_year = input("Enter returned year: ")
     self._validateinteger.validate_integer(returned_day)
     self._validateinteger.validate_integer(returned_month)
     self._validateinteger.validate_integer(returned_year)
     self._validatedate.validate_date(int(returned_day),
                                      int(returned_month),
                                      int(returned_year))
     self._srv.update_rental(
         int(rentalId),
         datetime.date(int(returned_year), int(returned_month),
                       int(returned_day)), True)
     RedoManager.delete()
예제 #13
0
 def removeBook(self):
     #asks the user for the id of the book he wants to delete and calls the remove function from services
     bookId = input("Book ID: ")
     self._validateinteger.validate_integer(bookId)
     self._srv.remove_book(bookId, True)
     RedoManager.delete()
예제 #14
0
 def removeClient(self):
     #asks the user for the id of the client he wants to delete and calls the remove function from services
     clientId = input("Client ID: ")
     self._validateinteger.validate_integer(clientId)
     self._srv.remove_client(clientId, True)
     RedoManager.delete()
예제 #15
0
def remove_rental_undo_handler(srv, rentalId, bookId, clientId, rentedDate,
                               returnedDate):
    RedoManager.register_operation(srv, RedoHandler.ADD_RENTAL, rentalId,
                                   bookId, clientId, rentedDate, returnedDate)
    srv.add_rental(rentalId, bookId, clientId, rentedDate, returnedDate, False)
예제 #16
0
 def redo(self):
     RedoManager.redo()
예제 #17
0
def add_client_undo_handler(srv, clientId, clientName):
    RedoManager.register_operation(srv, RedoHandler.REMOVE_CLIENT, clientId,
                                   clientName)
    srv.remove_client(clientId, False)