OtherParameter update api: suseendhiran

This commit is contained in:
suseendhiran17 2022-08-06 10:21:18 +05:30
parent f489736f8d
commit c54103230c
3 changed files with 54 additions and 51 deletions

View File

@ -1015,18 +1015,24 @@ exports.updateOtherParameters = async (req, res) =>
{ {
try try
{ {
id = req.body.id; req.body.forEach( async (element,index) =>
delete req.body.id;
// update value
OtherParameters.update(req.body,{ where: { id: id }}).then(data =>
{ {
id = element.id;
delete element.id;
// update value
OtherParameters.update(element,{ where: { id: id }}).then(data =>
{
if ([req.body].length - 1 == index) {
res.send({'status':200,'message':"success",'data':data}); res.send({'status':200,'message':"success",'data':data});
}
}) })
.catch(err => { .catch(err => {
res.send({'status':404, res.send({'status':404,
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" }); message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
}); });
});
} catch(err) { } catch(err) {
res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data" }); res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data" });

View File

@ -2201,6 +2201,8 @@ router.get("/otherParameterMaster", Mastercontroller.otherParameterMaster);
* @swagger * @swagger
* definitions: * definitions:
* updateOtherParameters: * updateOtherParameters:
* type: array
* items:
* type: object * type: object
* properties: * properties:
* id: * id:

View File

@ -213,21 +213,18 @@ function ApplicantChildTable(ApplicantName , LoanId , ApplicantId , Losid , Enti
// ApplicantsRelationship Table // ApplicantsRelationship Table
var ApplicantsRelationshipPromise = new Promise(async(resolve, reject) => var ApplicantsRelationshipPromise = new Promise(async(resolve, reject) =>
{ {
// if(EntityType == "Individual") if(EntityType == "Individual")
// { {
ApplicantsRelationshipData = { } ApplicantsRelationshipData = { }
Object.assign(ApplicantsRelationshipData, {name_of_the_individual : ApplicantName ,applicant_id: ApplicantId, loan_no_id: LoanId ,losid: Losid }); Object.assign(ApplicantsRelationshipData, {name_of_the_individual : ApplicantName ,applicant_id: ApplicantId, loan_no_id: LoanId ,losid: Losid });
// if (ApiArray.lstApplicantsRelationship.length != 0)
// {
await ApplicantsRelationship.create(ApplicantsRelationshipData) await ApplicantsRelationship.create(ApplicantsRelationshipData)
.then(data=>{ resolve("ApplicantsRelationship")}).catch(err=>{logMsg.info("ApplicantsRelationship Failed , Msg :" +err);}); .then(data=>{ resolve("ApplicantsRelationship")}).catch(err=>{logMsg.info("ApplicantsRelationship Failed , Msg :" +err);});
// } }
// }
}); });
// ResidenceAddressDetails Table // ResidenceAddressDetails Table
var ResidenceAddressDetailsPromise = new Promise(async(resolve, reject) => var ResidenceAddressDetailsPromise = new Promise(async(resolve, reject) =>
{ {
if(ApiArray.lstApplicantAddress.length != 0 /* && EntityType == "Individual" */) if(ApiArray.lstApplicantAddress.length != 0 && EntityType == "Individual" )
{ {
// ResidenceAddressDetails data // ResidenceAddressDetails data
ApiArray.lstApplicantAddress.forEach(async(ApplicantAddress,index) => ApiArray.lstApplicantAddress.forEach(async(ApplicantAddress,index) =>
@ -246,7 +243,6 @@ function ApplicantChildTable(ApplicantName , LoanId , ApplicantId , Losid , Enti
await ResidenceAddressDetails.create(ApplicantAddress) await ResidenceAddressDetails.create(ApplicantAddress)
.then(data=> .then(data=>
{ {
// logMsg.info("ResidenceAddressDetails inserted");
if ([ApiArray.lstApplicantAddress].length - 1 == index) if ([ApiArray.lstApplicantAddress].length - 1 == index)
{ {
resolve("ResidenceAddressDetails") resolve("ResidenceAddressDetails")
@ -255,26 +251,25 @@ function ApplicantChildTable(ApplicantName , LoanId , ApplicantId , Losid , Enti
.catch(err=>{logMsg.info("ResidenceAddressDetails Failed , Msg :" +err);}); .catch(err=>{logMsg.info("ResidenceAddressDetails Failed , Msg :" +err);});
} }
}); });
} }
}) })
// ResidenceAddressDetails Table // PropertyOwnershipIncomeConsidered Table
var PropertyOwnershipIncomeConsideredPromise = new Promise(async(resolve, reject) => var PropertyOwnershipIncomeConsideredPromise = new Promise(async(resolve, reject) =>
{ {
// if (product == "LFMP") if (Product == "LFMP")
// { {
PropertyOwnershipIncomeConsideredData = { } PropertyOwnershipIncomeConsideredData = { }
Object.assign(PropertyOwnershipIncomeConsideredData, {name_of_the_loan_applicants : ApplicantName ,applicant_id: ApplicantId, loan_no_id: LoanId ,losid: Losid }); Object.assign(PropertyOwnershipIncomeConsideredData, {name_of_the_loan_applicants : ApplicantName ,applicant_id: ApplicantId, loan_no_id: LoanId ,losid: Losid });
await PropertyOwnershipIncomeConsidered.create(PropertyOwnershipIncomeConsideredData) await PropertyOwnershipIncomeConsidered.create(PropertyOwnershipIncomeConsideredData)
.then(data=>{ resolve("PropertyOwnershipIncomeConsidered") }).catch(err=>{logMsg.info("PropertyOwnershipIncomeConsidered Failed , Msg :" +err);}); .then(data=>{ resolve("PropertyOwnershipIncomeConsidered") }).catch(err=>{logMsg.info("PropertyOwnershipIncomeConsidered Failed , Msg :" +err);});
// } }
}); });
Promise.all([ApplicantsRelationshipPromise, ResidenceAddressDetailsPromise, PropertyOwnershipIncomeConsideredPromise ]) Promise.all([ApplicantsRelationshipPromise, ResidenceAddressDetailsPromise, PropertyOwnershipIncomeConsideredPromise ])
.then((values) => { .then((values) => {
values.forEach(element => { values.forEach(element => {
logMsg.info(element+ " Data Creation Success for EntityId= "+EntityId); // [3, 1337, "foo"] logMsg.info(element+ " Data Creation Success for ApplicantId= "+ApplicantId); // [3, 1337, "foo"]
}); });
}) })