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 });
|
|
|
|
}
|
2024-10-22 18:43:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const getAllFunds = async (req, res) => {
|
|
|
|
try {
|
|
|
|
// const allFunds = await FundDetailsModal.find();
|
|
|
|
const allFunds = await FundDetailsModal.findOne();
|
|
|
|
res.status(200).json(allFunds);
|
|
|
|
} catch (error) {
|
|
|
|
res.status(500).json({ message: "Server error" });
|
|
|
|
}
|
|
|
|
};
|