} // Create private void FindCustomerOfficersAndAppointments(CompanyScoreModel model) { if (model.CompanyDetails == null || string.IsNullOrEmpty(model.CompanyDetails.CustomerFirstName) || string.IsNullOrEmpty(model.CompanyDetails.CustomerSurname) || model.CompaniesHouseModel == null || model.CompaniesHouseModel.Officers == null) { return; } //if foreach (var officer in model.CompaniesHouseModel.Officers) { if (!string.IsNullOrEmpty(officer.Name) && officer.Name.ToLowerInvariant().Contains(model.CompanyDetails.CustomerFirstName) && officer.Name.ToLowerInvariant().Contains(model.CompanyDetails.CustomerSurname)) { officer.IsCustomer = true; } //if if (officer.AppointmentOrder == null || officer.AppointmentOrder.Appointments == null) { continue; } //if foreach (var appointment in officer.AppointmentOrder.Appointments.Where(appointment => !string.IsNullOrEmpty(appointment.Name) && appointment.Name.ToLowerInvariant().Contains(model.CompanyDetails.CustomerFirstName) && appointment.Name.ToLowerInvariant().Contains(model.CompanyDetails.CustomerSurname))) { appointment.IsCustomer = true; } //foreach } //foreach } //FindCustomerOfficersAndAppointments
public void AddOwner(CompanyScoreModel oOwner) { if (ReferenceEquals(m_oSavedOwners, null)) { m_oSavedOwners = new SortedSet <string>(); m_oOwners = new List <CompanyScoreModel>(); } // if if (m_oSavedOwners.Contains(oOwner.company_ref_num)) { return; } m_oSavedOwners.Add(oOwner.company_ref_num); m_oOwners.Add(oOwner); } // AddOwner
private void BuildCompaniesHouseAlerts(ProfileSummaryModel summary, CompanyScoreModel companyScore) { if (companyScore.CompaniesHouseModel == null || companyScore.CompaniesHouseModel.Officers == null) { return; } var customerOfficer = companyScore.CompaniesHouseModel.Officers.FirstOrDefault(x => x.IsCustomer); if (customerOfficer != null && customerOfficer.AppointmentOrder != null && customerOfficer.AppointmentOrder.Appointments != null && customerOfficer.AppointmentOrder.Appointments.Count >= 5) { summary.Alerts.Warnings.Add(new AlertModel { Abbreviation = "MDC", Alert = string.Format("Applicant has appointments in {0} companies", customerOfficer.AppointmentOrder.Appointments.Count), AlertType = AlertType.Warning.DescriptionAttr(), Tab = ProfileTab.CompanyScore.DescriptionAttr() }); } if (customerOfficer != null && customerOfficer.AppointmentOrder != null && customerOfficer.AppointmentOrder.Appointments != null && customerOfficer.AppointmentOrder.Appointments.Any(x => x.CompanyStatus != "Active")) { summary.Alerts.Errors.Add(new AlertModel { Abbreviation = "DSL", Alert = string.Format("Applicant has appointments in companies with status {0}", customerOfficer .AppointmentOrder .Appointments .Where(x => x.CompanyStatus != "Active") .Select(x => x.CompanyStatus) .Aggregate((a, b) => a + ", " + b)), AlertType = AlertType.Error.DescriptionAttr(), Tab = ProfileTab.CompanyScore.DescriptionAttr() }); } }
} // BuildLimitedDashboardModel private void AddOwners(CompanyScoreModel oPossession, string sOwnerRegNum) { if (string.IsNullOrWhiteSpace(sOwnerRegNum)) { return; } ExperianLtdActionResult oLtdAr; try { oLtdAr = m_oServiceClient.Instance.CheckLtdCompanyCache(m_oContext.UserId, sOwnerRegNum); } catch (Exception e) { m_oLog.Alert(e, "Failed to load Experian parsed data for company '{0}'.", sOwnerRegNum); return; } // try if (!string.IsNullOrWhiteSpace(oLtdAr.Value.RegisteredNumber)) { oPossession.AddOwner(BuildLimitedScoreModel(oLtdAr)); } } // AddOwners
public ProfileSummaryModel CreateProfile(Customer customer, CreditBureauModel creditBureau, CompanyScoreModel companyScore) { TimeCounter tc = new TimeCounter("ProfileSummaryModel 1 building time for customer " + customer.Id); var summary = new ProfileSummaryModel(); using (tc.AddStep("BuildCustomerSummary Time taken")) { BuildCustomerSummary(summary, customer); } using (tc.AddStep("BuildCreditBureau Time taken")) { BuildCreditBureau(customer, summary, creditBureau); } using (tc.AddStep("AddDecisionHistory Time taken")) { AddDecisionHistory(summary, customer); } using (tc.AddStep("BuildRequestedLoan Time taken")) { BuildRequestedLoan(summary, customer); } using (tc.AddStep("BuildAlerts Time taken")) { BuildAlerts(summary, customer); } using (tc.AddStep("BuildCompaniesHouseAlerts Time taken")) { BuildCompaniesHouseAlerts(summary, companyScore); } log.Info(tc.ToString()); return(summary); }
} // constructor public CompanyScoreModel Create(Customer customer) { var model = new CompanyScoreModel { CompanyDetails = BuildDetails(customer) }; bool bHasCompany = false; var nBusinessType = TypeOfBusinessReduced.Personal; if (customer != null) { if (customer.Company != null) { nBusinessType = customer.Company.TypeOfBusiness.Reduce(); bHasCompany = true; } // if } // if if (!bHasCompany) { model.result = "No data found."; model.DashboardModel = new ComapanyDashboardModel { Error = "No data found.", }; return(model); } // if if (nBusinessType != TypeOfBusinessReduced.Limited) { CompanyDataForCompanyScoreActionResult oUnlimAr = m_oServiceClient.Instance.GetCompanyDataForCompanyScore( m_oContext.UserId, customer.Company.ExperianRefNum ); model.result = CompanyScoreModel.Ok; model.company_name = oUnlimAr.Data.BusinessName; model.company_ref_num = customer.Company.ExperianRefNum; model.Data = oUnlimAr.Data; model.DashboardModel = BuildNonLimitedDashboardModel(oUnlimAr.Data, customer.Company.ExperianRefNum); return(model); } // if ExperianLtdActionResult oLtdAr; try { oLtdAr = m_oServiceClient.Instance.CheckLtdCompanyCache(m_oContext.UserId, customer.Company.ExperianRefNum); model.CompaniesHouseModel = oLtdAr.CompaniesHouse; FindCustomerOfficersAndAppointments(model); } catch (Exception e) { m_oLog.Alert(e, "Failed to load Experian parsed data for a company '{0}'.", customer.Company.ExperianRefNum); model.result = "Failed to load data."; model.DashboardModel = new ComapanyDashboardModel { Error = "Failed to load data.", }; return(model); } // try if (string.IsNullOrWhiteSpace(oLtdAr.Value.RegisteredNumber)) { model.result = "No data found."; model.DashboardModel = new ComapanyDashboardModel { Error = "No data found.", }; return(model); } // if CompanyScoreModel oResult = BuildLimitedScoreModel(oLtdAr); oResult.CompanyDetails = model.CompanyDetails; foreach (var oSha in oLtdAr.Value.GetChildren <ExperianLtdShareholders>()) { AddOwners(oResult, oSha.RegisteredNumberOfALimitedCompanyWhichIsAShareholder); } AddOwners(oResult, oLtdAr.Value.RegisteredNumberOfTheCurrentUltimateParentCompany); return(oResult); } // Create