def store(self, entity): self.__grades.store(entity) redo = FunctionCall(self.store, entity) undo = FunctionCall(self.delete, entity) operation = Operation(redo, undo) self._undoController.recordOperation(operation)
def store(self, entity): status = self.__repository.store(entity) if status != False: redo = FunctionCall(self.store, entity) undo = FunctionCall(self.delete, entity.getID()) operation = Operation(redo, undo) self._undoController.recordOperation(operation) return status
def delete(self, ID): entity = self.__repository.delete(ID) if entity != False: myList = self.__gradesRepository.getAllStudentGrades(ID) self.__gradesRepository.deleteByStud(ID) redo = FunctionCall(self.delete, ID) undo = FunctionCall(self.store, entity) operation = Operation(redo, undo) self._undoController.recordOperation(operation) for i in myList: redo = FunctionCall(self.__gradesRepository.delete, i) undo = FunctionCall(self.__gradesRepository.store, i) operation = Operation(redo, undo) self._undoController.recordOperation(operation) return True return False
def update(self, entity): entityForUndo = self.__repository.find(entity.getID()) status = self.__repository.update(entity) if status != False: redo = FunctionCall(self.update, entity) undo = FunctionCall(self.update, entityForUndo) self._undoController.newOperation() operation = Operation(redo, undo) self._undoController.recordOperation(operation) return status