def update_client(self, id, nume, prenume, CNP, serie_buletin, numar_buletin, taxa): """ Update a client :param id: int id of client :param nume: str, name of client :param prenume: str, fist name of client :param CNP: str, CNP of client :param serie_buletin: str, series of client :param numar_buletin: str, number of client :param taxa: float, rates of client :return: - """ for client in self.get_all(): if id == client.get_id(): client_undo = Client(client.get_id(), client.get_nume(), client.get_prenume(), client.get_CNP(), client.get_serie_buletin(), client.get_numar_buletin(), client.get_taxa()) break client = Client(id, nume, prenume, CNP, serie_buletin, numar_buletin, taxa) self.__repository.update(client) self.__undo_operations.append( lambda: self.__repository.update(client_undo)) self.__redo_operations.append(lambda: self.__repository.update(client))
def add(self, id_client, name): client = Client(id_client, name) # TODO: validate self.__client_repo.add(client)
def clientsInitialize(self): clientRepo = Repository() firstName = [ "Bogdan", "Andrei", "Cristi", "Patrick", "Gabriel", "Laura", "Alexandra", "Andreea", "Robert", "Claudiu", "Mirel", "Carmen", "Darius", "Robert", "Macanache" ] secondName = [ "Suciu", "Petru", "Andras", "Pop", "Cosmulei", "Micu", "Crivei", "Bota", "Botis", "Stejerean", "Vincze", "Somotecan", "Salvia" ] i = 0 while i <= 100: clientRepo.add( Client((i * 4 + i % 3 + 1) // 2 + 1, random.choice(firstName) + " " + random.choice(secondName))) i += 1 i = 0 while i < len(clientRepo._list): # print(clientRepo._list[i]) i += 1 return clientRepo
def addClient(self, an_id, name): ''' Adds a client to the list of clients Input: an_id - int name - string Output: Adds a client to the client list ''' undo = FunctionCall(self.removeClient, an_id) redo = FunctionCall(self.addClient, an_id, name) op = Operation(undo, redo) self._UndoService.addOperation(op) self._clientRepo.add(Client(an_id, name))
def readFromFile(self): try: f = open(self._fileName, "r") line = f.readline() while len(line) > 0: parts = line.split(";") client = Client(int(parts[0]), parts[1]) Repository.add(self, client) line = f.readline() f.close() except: pass
def add_client(self, id, nume, prenume, CNP, serie_buletin, numar_buletin, taxa): """ Add a client :param id: int id of client :param nume: str, name of client :param prenume: str, fist name of client :param CNP: str, CNP of client :param serie_buletin: str, series of client :param numar_buletin: str, number of client :param taxa: float, rates of client :return: - """ client = Client(id, nume, prenume, CNP, serie_buletin, numar_buletin, taxa) self.__repository.add(client) self.__undo_operations.append(lambda: self.__repository.delete(id)) self.__redo_operations.append(lambda: self.__repository.add(client))
def update(self, id_client, new_name): new_client = Client(id_client, new_name) self.__client_repo.update(new_client)
@author: Vlad ''' from Repositories.Repository import GenericRepository from Repositories.RentalRepository import RentalRepository from Controller.ClientController import ClientController from Controller.CarController import CarController from Controller.RentalController import RentalController from UI.Console import Console from Domain.Client import Client from Domain.Car import Car from Repositories.ClientRepository import ClientRepository from Repositories.CarRepository import CarRepository repo_clients = ClientRepository() repo_clients.add(Client("1", "client1")) repo_clients.add(Client("2", "client2")) repo_clients.add(Client("3", "client3")) repo_cars = CarRepository() repo_cars.add(Car("1", "car1")) repo_cars.add(Car("2", "car2")) repo_cars.add(Car("3", "car3")) repo_rentals = RentalRepository() ctrl_clients = ClientController(repo_clients) ctrl_cars = CarController(repo_cars) ctrl_rentals = RentalController(repo_clients, repo_cars, repo_rentals) ui = Console(ctrl_cars, ctrl_clients, ctrl_rentals)