vicinityManager/server/controllers/api/api.js
/**
 * Creates a registration request that needs to be approved
 *
 * @param {Object} data
 * password, userName, email, occupation, companyName, companyLocation,
 * businessId, termsAndConditions
 * @return {String} Acknowledgement
 */
Creates a registration request that needs to be approved
@param {Object} data
password, userName, email, occupation, companyName, companyLocation,
businessId, termsAndConditions
@return {String} Acknowledgement
Creates a registration request that needs to be approved @param { Object } data password userName email occupation companyName companyLocation businessId termsAndConditions @return { String } Acknowledgement
function createOrganisation(req, res, next) {
  var data = req.body;
  var finalRes;
  data.type = "newCompany";
  sRegister.findDuplicatesUser(data)
  .then(function(dup){
    if(!dup){
      return sRegister.findDuplicatesCompany(data);
    }else{
      finalRes = {error: false, message: "Mail already registered"};
      return true; 
    }
  }).then(function(dup){
    if(!dup){
      sRegister.requestReg(data, function(err, response){
        res.json({error: err, message: response});
      });
    }else{
      if(typeof finalRes !== "object"){ finalRes = {error: false, message: "Company name or business ID already exist"}; } 
      res.json(finalRes);
    }
  }).catch(function(err){
    res.json({error: true, message: err});
  });
}
function createOrganisation ( req , res , next ) { var data = req . body ; var finalRes ; data . type = "newCompany" ; sRegister . findDuplicatesUser ( data ) . then ( function ( dup ) { if ( ! dup ) { return sRegister . findDuplicatesCompany ( data ) ; } else { finalRes = { error : false , message : "Mail already registered" } ; return true ; } } ) . then ( function ( dup ) { if ( ! dup ) { sRegister . requestReg ( data , function ( err , response ) { res . json ( { error : err , message : response } ) ; } ) ; } else { if ( typeof finalRes !== "object" ) { finalRes = { error : false , message : "Company name or business ID already exist" } ; } res . json ( finalRes ) ; } } ) . catch ( function ( err ) { res . json ( { error : true , message : err } ) ; } ) ; }
Creates a registration request that needs to be approved
 @param {Object} data
 password, userName, email, occupation, companyName, companyLocation,
 businessId, termsAndConditions
 @return {String} Acknowledgement
Creates a registration request that needs to be approved @param { Object } data password userName email occupation companyName companyLocation businessId termsAndConditions @return { String } Acknowledgement
// Duplicates found at mail stage // Dups found at org stage