Esempio n. 1
0
def addAClient(commandInPieces):
    # adds a client to the repository
    # input - details about the client as a list
    repoCaller = Repo()
    clientId = commandInPieces[1]
    clientName = commandInPieces[2]
    undoFunction = Undo("removeC", ["undo", clientId, clientName])
    if commandInPieces[0] != "undo":
        repoCaller.addToListOfOperations(undoFunction)
        repoCaller.setRedoFalse()
    newClient = Client(clientId, clientName)
    try:
        validateAClient(newClient)
        repoCaller.addTheClientToTheRepo(newClient)
        repoCaller.loadIntoFiles()
        repoCaller.loadIntoPickle()
    except ClientAlreadyExistsError:
        print(str(ClientAlreadyExistsError()))
    return False