public String add(MemoriCommand command, GoogleSync googleSync) { if (maxIdSet == false) findMaxId(); maxId++; MemoriEvent event = new MemoriEvent( command.getName(), command.getStart(), command.getEnd(), maxId, "google", command.getDescription(), command.getLocation()); memoriCalendar.add(event); googleSync.executeCommand(event, command); return MESSAGE_ADD; }
private String update(MemoriCommand command, GoogleSync googleSync) { MemoriEvent originalEvent; if (memoriCalendar.isEmpty()) { return MESSAGE_EMPTYFILE; } else { int index = command.getIndex(); if (memoriCalendar.size() < index) { return LINE_INDEX_DOES_NOT_EXISTS; } else { originalEvent = memoriCalendar.get(index - 1); originalEvent.update( command.getName(), command.getStart(), command.getEnd(), command.getDescription(), command.getLocation()); googleSync.executeCommand(originalEvent, command); return String.format(MESSAGE_UPDATE, index); } } }