예제 #1
0
 def add(self, book):
     if Validate.check_book(None, book) is False:
         raise ServiceError('Invalid input!')
     self._list_books.add(book)
     undo = FunctionCall(self._list_books.delete, book)
     redo = FunctionCall(self._list_books.add, book)
     op = Operation(undo, redo)
     self._undo_controller.recordOperation(op)
예제 #2
0
 def delete(self, client, var=True):
     if Validate.check_client(self, client) is False:
         raise ServiceError('Invalid input!')
     self._list_clients.delete(client)
     if var == True:
         undo = FunctionCall(self._list_clients.add, client)
         redo = FunctionCall(self._list_clients.delete, client)
         op = Operation(undo, redo)
         return op
예제 #3
0
 def add(self, client):
     # this function will get a client and add it to the list of clients
     if Validate.check_client(self, client) is False:
         raise ServiceError('Invalid input!')
     self._list_clients.add(client)
     undo = FunctionCall(self._list_clients.delete, client)
     redo = FunctionCall(self._list_clients.add, client)
     op = Operation(undo, redo)
     self._undo_controller.recordOperation(op)
예제 #4
0
 def delete(self, book, variable=True):
     # this function deletes an object from the list
     if Validate.check_book(None, book) is False:
         raise ServiceError('Invalid input!')
     if variable == True:
         self._list_books.delete(book)
         undo = FunctionCall(self.add, book)
         redo = FunctionCall(self.delete, book)
         operation = Operation(undo, redo)
         return operation
예제 #5
0
 def update(self, client, new_name):
     if Validate.check_client(self, client) is False:
         raise ServiceError('Invalid input!')
     client = self.find_client_by_id(client.id)
     old_name = client.name
     client.set_name(new_name)
     self._list_clients.update(client)
     undo = FunctionCall(self.update, client, old_name)
     redo = FunctionCall(self.update, client, new_name)
     op = Operation(undo, redo)
     self._undo_controller.recordOperation(op)
예제 #6
0
 def search(self, client):
     if Validate.check_client(self, client) is False:
         raise ServiceError('Invalid input!')
     return self._list_clients.search(client)
예제 #7
0
 def search(self, book):
     # this function returns the object if it is in the list
     if Validate.check_book(None, book) is False:
         raise ServiceError('Invalid input!')
     return self._list_books.search(book)