Skip to content
This repository has been archived by the owner on Jun 21, 2019. It is now read-only.

Commit

Permalink
Get RSVP on attendeeId
Browse files Browse the repository at this point in the history
  • Loading branch information
ASankaran committed Feb 23, 2018
1 parent 25fa0dc commit 789eaee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 2 additions & 4 deletions api/v1/controllers/RecruiterInterestController.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ const router = require('express').Router();
function createInterest(req, res, next) {
services.RegistrationService
.findAttendeeById(req.body.attendeeUserId, false)
.then((attendee) => {
return services.RecruiterInterestService
.then((attendee) => services.RecruiterInterestService
.createInterest(req.user.get('id'), attendee.get('id'), req.body.comments, req.body.favorite)
.then((result) => {
res.body = result.toJSON();
return next();
});
})
}))
.catch((error) => next(error));
}

Expand Down
9 changes: 8 additions & 1 deletion api/v1/services/RSVPService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ const utils = require('../utils');
* @param {integer} id the id of the RSVP to find
* @returns {Promise} the resolved rsvp
*/
module.exports.getRSVPById = (id) => RSVP.findById(id);
module.exports.getRSVPById = (id) => RSVP.findByAttendeeId(id).then((model) => {
if (_.isNull(model)) {
const message = 'An RSVP cannot be found for the given attendee';
const source = 'attendeeId';
throw new errors.NotFoundError(message, source);
}
return model;
});

/**
* Creates an RSVP and sets the users attendee role to active
Expand Down

0 comments on commit 789eaee

Please sign in to comment.