private static async Task ValidateFundReferences(this MasterSideLetterDataAccess dataAccess, Fund fund)
        {
            if (!string.IsNullOrEmpty(fund.SponsorName))
            {
                var sponsor = await dataAccess.GetOrCreateSponsorAsync(fund.SponsorName);

                fund.SponsorId = sponsor.Id;
            }

            if (!string.IsNullOrEmpty(fund.StrategyName))
            {
                var strategy = await dataAccess.GetOrCreateStrategyAsync(fund.StrategyName);

                fund.StrategyId = strategy.Id;
            }

            if (!string.IsNullOrEmpty(fund.BusinessUnitName))
            {
                var businessUnit = await dataAccess.GetOrCreateBusinessUnitAsync(fund.BusinessUnitName);

                fund.BusinessUnitId = businessUnit.Id;
            }
        }
Exemple #2
0
        private static async Task ValidateFundInvestorAsync(this MasterSideLetterDataAccess dataAccess, FundInvestor fundInvestor)
        {
            if (!string.IsNullOrEmpty(fundInvestor.FundName))
            {
                var fund = await dataAccess.GetOrCreateFundAsync(
                    fundInvestor.FundName,
                    fundInvestor.FundSponsorName,
                    fundInvestor.FundBusinessUnitName,
                    fundInvestor.FundStrategyName,
                    fundInvestor.FundYear,
                    fundInvestor.FundSize
                    );

                var updated = false;
                if (fund.SponsorName != fundInvestor.FundSponsorName)
                {
                    updated = true;
                    var sponsor = await dataAccess.GetOrCreateSponsorAsync(fundInvestor.FundSponsorName);

                    fund.SponsorId   = sponsor.Id;
                    fund.SponsorName = sponsor.Name;
                }

                if (fund.BusinessUnitName != fundInvestor.FundBusinessUnitName)
                {
                    updated = true;
                    var businessUnit = await dataAccess.GetOrCreateBusinessUnitAsync(fundInvestor.FundBusinessUnitName);

                    fund.BusinessUnitId   = businessUnit.Id;
                    fund.BusinessUnitName = businessUnit.Name;
                }

                if (fund.StrategyName != fundInvestor.FundStrategyName)
                {
                    updated = true;
                    var strategy = await dataAccess.GetOrCreateStrategyAsync(fundInvestor.FundStrategyName);

                    fund.StrategyId   = strategy.Id;
                    fund.StrategyName = strategy.Name;
                }

                if (fund.Year != fundInvestor.FundYear)
                {
                    updated   = true;
                    fund.Year = fundInvestor.FundYear;
                }

                if (fund.Size != fundInvestor.FundSize)
                {
                    updated   = true;
                    fund.Size = fundInvestor.FundSize;
                }

                if (updated)
                {
                    await dataAccess.UpdateFundAsync(fund);
                }

                fundInvestor.FundId = fund.Id;
            }

            if (!string.IsNullOrEmpty(fundInvestor.InvestorName))
            {
                var investor = await dataAccess.GetOrCreateInvestorAsync(fundInvestor.InvestorName, fundInvestor.InvestorType);

                if (investor.InvestorType != fundInvestor.InvestorType)
                {
                    investor.InvestorType = fundInvestor.InvestorType;
                    await dataAccess.UpdateInvestorAsync(investor);
                }
                fundInvestor.InvestorId = investor.Id;
            }
        }