public static List <InsuranceSubType> GetDealByInsuranceTypeAndCompany(int insuranceTypeID, int companyID) { List <Deal> dealList = Deal.GetByInsuranceCompany(companyID); List <InsuranceSubType> insSubTypeList = new List <InsuranceSubType>(); List <Brokerage> brokerageList = new List <Brokerage>(); foreach (Deal d in dealList) { brokerageList.AddRange(d.Brokerages.ToList()); } foreach (Brokerage b in brokerageList) { if (b.InsuranceSubType.InsuranceTypeID == insuranceTypeID) { if (!insSubTypeList.Contains(b.InsuranceSubType)) { insSubTypeList.Add(b.InsuranceSubType); } } } return(insSubTypeList); }
public static List <InsuranceType> GetByCompanyWithLife(int companyID) { List <Deal> dealList = Deal.GetByCompanyID(companyID); List <InsuranceType> insList = new List <InsuranceType>(); List <Brokerage> brokList = Brokerage.GetByDeals(dealList); foreach (Brokerage b in brokList) { if (b.IsActive && !insList.Contains(b.InsuranceSubType.InsuranceType)) { insList.Add(b.InsuranceSubType.InsuranceType); } } List <LifeDeal> lst = LifeDeal.GetByInsuranceCompany(companyID); foreach (LifeDeal ld in lst) { if (!insList.Contains(ld.InsuranceSubType.InsuranceType)) { insList.Add(ld.InsuranceSubType.InsuranceType); } } return(insList.OrderBy(c => c.Code).ToList()); }