Example #1
0
    def remove(self,rentalId):
        if not self.findRentalById(rentalId):
            raise NotFoundException("Rental does not exist")

        for rental in self._rentalList:
            if rental.getRentalId() == rentalId:
                del self._rentalList[self._rentalList.index(rental)]
    def remove(self,movieId):
        if not self.exists(movieId):
            raise NotFoundException("Movie does not exist")

        for movie in self._movieList:
            if movie.getMovieId() == movieId:
                del self._movieList[self._movieList.index(movie)]
    def remove(self, movieId):
        '''
        The function will remove the given movie from the list

        :param movieId: the id of the movie to be removed

        '''
        if self.__repository.exists(movieId):
            self.__repository.remove(movieId)
        else:
            raise NotFoundException("Movie not found")
    def modifyMovieGenre(self, movieId, newGenre):
        '''
        Function will call the repo function to modify genre after validation
        :param newGenre: the new genre
        '''

        self.__validator.validateGenre(newGenre)

        if self.__repository.exists(movieId):
            self.__repository.modifyGenre(movieId, newGenre)
        else:
            raise NotFoundException("Movie not found")
    def modifyMovieDescription(self, movieId, newDescription):
        '''
        Function will call the repo function to modify description after validation
        :param newDescription: the new description
        '''

        self.__validator.validateDescription(newDescription)

        if self.__repository.exists(movieId):
            self.__repository.modifyDescription(movieId, newDescription)
        else:
            raise NotFoundException("Movie not found")
    def complete(self, rentalId, year, month, day):
        '''
        Function will validate the completion parameters of a rental and call the completion method
        from the parent class
        Function will complete a rental
        :param rentalId: the id of the rental to be completed
        :param year: the year of completion
        :param month: the month of completion
        :param day: the day of completion
        '''
        try:
            finalYear = int(year)
            finalMonth = int(month)
            finalDay = int(day)
            id = int(rentalId)
        except ValueError:
            print("Rental ID must be int")
            return

        if not self.__repository.exists(id):
            raise NotFoundException("Rental not exists")

        self.__repository.complete(id, date(finalYear, finalMonth, finalDay))
 def findMovieById(self,movieId):
     for movie in self._movieList:
         if movie.getMovieId() == movieId:
             return movie
     raise NotFoundException("Movie not found")
Example #8
0
 def findRentalById(self,rentalId):
     for rental in self._rentalList:
         if rental.getRentalId() == rentalId:
             return rental
     raise NotFoundException("Rental not found")
    def changeRentalStatus(self, clientId):
        if not self.__repository.exists(clientId):
            raise NotFoundException("Client not found")

        self.__repository.changeRentalStatus(clientId)
    def modify(self, clientId, newValue):
        if not self.__repository.exists(clientId):
            raise NotFoundException("Client not found")

        self.__validator.validateName(newValue)
        self.__repository.modifyName(clientId, newValue)
 def remove(self, clientId):
     if not self.__repository.exists(clientId):
         raise NotFoundException("Client does not exist")
     self.__repository.remove(clientId)