コード例 #1
0
void HistoryHandler::deleteEvent (CommandParser& test)
{
	int displayIndex, i;
		
	displayIndex=atoi(test.getInputIndex().c_str());
	string eventId = displayList[displayIndex-1].getId();
	string date=eventId.substr(0,8);
	Date dateObj=masterList[0].dateStringToObject(date);
	int dateIndex=masterList[0].dateDifference(dateObj);
	int indexToDelete=masterList[dateIndex].getIndex(eventId);
			
	commandOrder.push("Delete");
	eventOrder.push(masterList[dateIndex].getEvent(indexToDelete));
	masterList[dateIndex].deleteEvent(indexToDelete);
}
コード例 #2
0
void HistoryHandler::editEvent (CommandParser& test)
{
	int displayIndex=atoi(test.getInputIndex().c_str());
	if(displayIndex>displayList.size())
		throw TempusException(TempusException::INVALID_INDEX_EXCEPTION);
	if(!test.hasWords())
		throw TempusException(TempusException::INVALID_EDIT_EXCEPTION, "No Details Entered");
	if(!test.hasDate())
		throw TempusException(TempusException::INVALID_EDIT_EXCEPTION, "Only Date Can Be Edited In Archive");
	string id = displayList[displayIndex-1].getId();
	string date=id.substr(0,8);
	Date dateObj=masterList[0].dateStringToObject(date);
	int dateIndex=masterList[0].dateDifference(dateObj);
	int indexToEdit=masterList[dateIndex].getIndex(id);

	assert(indexToEdit!=-1);

	Event eventObj2 = masterList[dateIndex].getEvent(indexToEdit);
	if (test.hasTime() && !test.hasDate())
		throw TempusException(TempusException::INVALID_EDIT_EXCEPTION, "Cannot Edit Time In Archive");
	deleteEvent(test);
		
	stringstream input;
	input << eventObj2.getName();
	if (eventObj2.getLocation()!="")
		input << " Location " << eventObj2.getLocation();
	input << " Date " << test.getInputDate();
	if (eventObj2.getEventType()!="d")
		input << " Time ";
	else
		input << " By ";
	
	if (test.hasTime())
		input << test.getStartTimeObj().formatCompleteTime(test.getEndTimeObj());
	else
		input  << eventObj2.getStartTime().formatCompleteTime(eventObj2.getEndTime());

	test.setStatus(eventObj2.getEventStatus());
	test.setInputDetails(input.str());
}