function editEvent(auth, req, res) {
	var calendar = google.calendar('v3');

	// check if the eventId is given or not
	if( req.body.id ){
		// form the request data object
		var event = {
			'summary': req.body.summary ? req.body.summary : '',
			'location': req.body.location ? req.body.location : '',
			'description': req.body.description ? req.body.description : '',
			'start': {
				'dateTime': req.body.start_datetime ? moment(req.body.start_datetime).format("YYYY-MM-DDTHH:MM:SS.SSSZ") : '',
				'timeZone': 'Asia/Hong_Kong',
			},
			'end': {
				'dateTime': req.body.end_datetime ? moment(req.body.end_datetime).format("YYYY-MM-DDTHH:MM:SS.SSSZ") : '',
				'timeZone': 'Asia/Hong_Kong',
			},
			'recurrence': [
				
			],
			'attendees': [
				
			],
			'reminders': {
				'useDefault': false,
				'overrides': [
					{'method': 'email', 'minutes': 24 * 60},
					{'method': 'popup', 'minutes': 10},
				],
			},
		};

		calendar.events.update({
			auth: auth,
			eventId: req.body.id,
			calendarId: 'primary',
			resource: event,
		}, function(err, updated_event) {
			req.flash('success', 'Update the event "'+req.body.summary+'" successfully');
			
			if (err) {
				req.flash('danger', 'Edit event fail. There was an error contacting the Calendar service: ' + err);
			}

			res.locals.messages = req.flash();
			res.redirect('/');
		});
	}else{
		// halt if eventId is missing
		req.flash('danger', 'Missing Event ID');
		res.locals.messages = req.flash();
		res.redirect('/');
		return;
	}
}
/**
 * Edit a single event with specific eventId
 *
 */
Edit a single event with specific eventId
Edit a single event with specific eventId
function editEvent(auth, req, res) {
	var calendar = google.calendar('v3');
	if( req.body.id ){
		var event = {
			'summary': req.body.summary ? req.body.summary : '',
			'location': req.body.location ? req.body.location : '',
			'description': req.body.description ? req.body.description : '',
			'start': {
				'dateTime': req.body.start_datetime ? moment(req.body.start_datetime).format("YYYY-MM-DDTHH:MM:SS.SSSZ") : '',
				'timeZone': 'Asia/Hong_Kong',
			},
			'end': {
				'dateTime': req.body.end_datetime ? moment(req.body.end_datetime).format("YYYY-MM-DDTHH:MM:SS.SSSZ") : '',
				'timeZone': 'Asia/Hong_Kong',
			},
			'recurrence': [
			],
			'attendees': [
			],
			'reminders': {
				'useDefault': false,
				'overrides': [
					{'method': 'email', 'minutes': 24 * 60},
					{'method': 'popup', 'minutes': 10},
				],
			},
		};
		calendar.events.update({
			auth: auth,
			eventId: req.body.id,
			calendarId: 'primary',
			resource: event,
		}, function(err, updated_event) {
			req.flash('success', 'Update the event "'+req.body.summary+'" successfully');
			if (err) {
				req.flash('danger', 'Edit event fail. There was an error contacting the Calendar service: ' + err);
			}
			res.locals.messages = req.flash();
			res.redirect('/');
		});
	}else{
		req.flash('danger', 'Missing Event ID');
		res.locals.messages = req.flash();
		res.redirect('/');
		return;
	}
}
function editEvent ( auth , req , res ) { var calendar = google . calendar ( 'v3' ) ; if ( req . body . id ) { var event = { 'summary' : req . body . summary ? req . body . summary : '' , 'location' : req . body . location ? req . body . location : '' , 'description' : req . body . description ? req . body . description : '' , 'start' : { 'dateTime' : req . body . start_datetime ? moment ( req . body . start_datetime ) . format ( "YYYY-MM-DDTHH:MM:SS.SSSZ" ) : '' , 'timeZone' : 'Asia/Hong_Kong' , } , 'end' : { 'dateTime' : req . body . end_datetime ? moment ( req . body . end_datetime ) . format ( "YYYY-MM-DDTHH:MM:SS.SSSZ" ) : '' , 'timeZone' : 'Asia/Hong_Kong' , } , 'recurrence' : [ ] , 'attendees' : [ ] , 'reminders' : { 'useDefault' : false , 'overrides' : [ { 'method' : 'email' , 'minutes' : 24 * 60 } , { 'method' : 'popup' , 'minutes' : 10 } , ] , } , } ; calendar . events . update ( { auth : auth , eventId : req . body . id , calendarId : 'primary' , resource : event , } , function ( err , updated_event ) { req . flash ( 'success' , 'Update the event "' + req . body . summary + '" successfully' ) ; if ( err ) { req . flash ( 'danger' , 'Edit event fail. There was an error contacting the Calendar service: ' + err ) ; } res . locals . messages = req . flash ( ) ; res . redirect ( '/' ) ; } ) ; } else { req . flash ( 'danger' , 'Missing Event ID' ) ; res . locals . messages = req . flash ( ) ; res . redirect ( '/' ) ; return ; } }
Edit a single event with specific eventId
Edit a single event with specific eventId
// check if the eventId is given or not // form the request data object // halt if eventId is missing