estatesfunding/ef-api/controllers/fundDetails.js

37 lines
1021 B
JavaScript
Raw Normal View History

2024-10-21 14:21:48 +00:00
import FundDetailsModal from "../models/fundDetails.js"
export const submitFundDetails = async (req, res) => {
const { propertyOwnerId, investorId, investmentAmount, ownershipPercentage, propertyId } = req.body;
const newFundDetail = new FundDetailsModal({
propertyOwnerId,
investorId,
investmentAmount,
ownershipPercentage,
propertyId
});
console.log("newFundDetail", newFundDetail)
try {
const savedFundDetail = await newFundDetail.save();
res.status(201).json(savedFundDetail);
} catch (error) {
res.status(500).json({ message: error.message });
}
};
export const getFundDetailsById = async (req, res) => {
const { id } = req.params;
try {
const fundDetails = await FundDetailsModal.findOne({ propertyId: id });
if (!fundDetails) {
return res.status(404).json({ message: "Fund details not found" });
}
res.status(200).json(fundDetails);
} catch (error) {
res.status(500).json({ message: error.message });
}
};