示例#1
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());
}
示例#2
0
void HistoryHandler::showEvents (CommandParser test)
{
	Date date;
	if (test.hasName())
	{
		displayList.clear();
		searchInputParameter(test.getInputName(), "name");
	}
	
	else if (test.hasDate())
	{
		showParticularDate(test.getDateObj());
	}

	else if (test.hasLocation())
	{
		displayList.clear();
		searchInputParameter(test.getInputLocation(), "location");
	}
}