37 lines
1021 B
JavaScript
37 lines
1021 B
JavaScript
|
|
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 });
|
|
}
|
|
}; |