def add_rent(self, rentid, movieid, clientid, rented_date, due_date, returned_date): rent = Rent(rentid, movieid, clientid, rented_date, due_date, returned_date) clientidd = Client(clientid, None) self.__repoClient.search(clientidd) movieid = Movie(movieid, None, None, None) self.__repoMovie.search(movieid) clients = [] l = self.__repoRent.get_all() for i in range(len(l)): if l[i].get_clientid() == rent.get_clientid(): clients.append(l[i]) movies = [] l = self.__repoRent.get_all() for i in range(len(l)): if l[i].get_movieid() == rent.get_movieid(): movies.append(l[i]) self.__validRent.validate_rent(rent, movies, clients) self.__repoRent.add(rent) rent = copy.deepcopy(rent) action = UndoAction(self.__repoRent.remove, self.__repoRent.add, rent, None) self.__undoActions.push(action) self.__redoActions.clear()
def remove_movie_element(self, idmovie): """ this function remove a movie element then the movie element is verificated if it is a good one then it is removed from list otherwise an error is displayed """ movie = Movie(idmovie, None, None, None) movie2 = self.__repo.search(movie) self.__repo.remove(movie) action = UndoAction(self.__repo.add, self.__repo.remove, movie2, None) self.__undoActions.push(action) self.__redoActions.clear()
def add_movie_element(self, movie_id, title, description, genre): """ this function create a movie element then the movie element is verificated if it is a good one then it is added to list otherwise an error is displayed """ movie = Movie(movie_id, title, description, genre) self.__valid.validate_movie(movie) self.__repo.add(movie) action = UndoAction(self.__repo.remove, self.__repo.add, movie, None) self.__undoActions.push(action) self.__redoActions.clear()
def remove_client_element(self, clientid): """ this function create a client element then the client element is verificated if it is a good one then it is removed from the list otherwise an error is displayed """ client = Client(clientid, None) client = self.__repoClient.remove(client) action = UndoAction(self.__repoClient.add, self.__repoClient.remove, client, None) self.__undoActions.push(action) self.__redoActions.clear()
def add_client_element(self, clientid, name): """ this function create a client element then the cleint element is verificated if it is a good one then it is added to list otherwise an error is displayed """ client = Client(clientid, name) self.__validClient.validate_client(client) self.__repoClient.add(client) action = UndoAction(self.__repoClient.remove, self.__repoClient.add, client, None) self.__undoActions.push(action) self.__redoActions.clear()
def update_movie_element(self, movied, title, description, genre): """ this function update a movie element then the movie element is verificated if it is a good one then it is updated otherwise an error is displayed """ movie = Movie(movied, title, description, genre) self.__valid.validate_movie(movie) movie3 = Movie(movied, title, description, genre) movie2 = self.__repo.search(movie3) self.__repo.update(movie) action = UndoAction(self.__repo.update, self.__repo.update, movie2, movie) self.__undoActions.push(action) self.__redoActions.clear()
def update_client_element(self, clientid, name): """ this function update a client element a client element is created if it is a good one then it is updated otherwise an error is displayed """ client = Client(clientid, name) self.__validClient.validate_client(client) client3 = Client(clientid, None) client2 = self.__repoClient.search(client3) self.__repoClient.update(client) action = UndoAction(self.__repoClient.update, self.__repoClient.update, client2, client) self.__undoActions.push(action) self.__redoActions.clear()
def return_movie(self, rentid, movieid, clientid, rented_date, due_date, returned_date): q = Rent(rentid, movieid, clientid, rented_date, due_date, returned_date) k = Rent(rentid, None, None, None, None, None) rent2 = self.__repoRent.search(q) rent3 = copy.deepcopy(rent2) rent = self.__repoRent.search(k) rent.set_returned_date(returned_date) l = self.__repoRent.search(q) self.__validRent.validate_return(rent, l) self.__repoRent.update(rent) rent = copy.deepcopy(rent) action = UndoAction(self.__repoRent.update, self.__repoRent.update, rent3, rent) self.__undoActions.push(action) self.__redoActions.clear()