private static Summary GetSummaryModel(CreditBureauModel model)
        {
            var summary = new Summary();

            summary.Score = model.Consumer.Score;
            summary.ConsumerIndebtednessIndex = model.Consumer.CII;
            summary.CheckDate             = model.Consumer.CheckDate;
            summary.Validtill             = model.Consumer.CheckValidity;
            summary.IsDataRelevant        = model.Consumer.IsDataRelevant;
            summary.WorstCurrentstatus    = model.Consumer.WorstCurrentStatus;
            summary.WorstHistoricalstatus = model.Consumer.WorstCurrentStatus3M;
            summary.Numberofdefaults      = model.Consumer.NumberOfDefaults;
            summary.Accounts               = model.Consumer.NumberOfAccounts;
            summary.CCJs                   = model.Consumer.NumberOfCCJs;
            summary.MostrecentCCJ          = model.Consumer.AgeOfMostRecentCCJ;
            summary.TotalCCJValue          = model.Consumer.TotalCCJValueStr;
            summary.Creditcardutilization  = model.Consumer.CreditCardUtilization;
            summary.Enquiriesinlast6months = model.Consumer.EnquiriesLast6M;
            summary.Enquiriesinlast3months = model.Consumer.EnquiriesLast3M;
            if (model.Consumer.ConsumerAccountsOverview != null)
            {
                summary.Totalbalance = model.Consumer.ConsumerAccountsOverview.Balance_Total;
            }
            summary.AML      = model.AmlInfo.AMLResult;
            summary.AMLnum   = model.AmlInfo.AuthenticationIndex.ToString(CultureInfo.InvariantCulture);
            summary.BWA      = model.BavInfo.BankAccountVerificationResult;
            summary.BWAnum   = GetBwaScoreInfo(model.BavInfo);
            summary.ThinFile = model.Consumer.AccountsInformation == null || model.Consumer.AccountsInformation.Length == 0;
            return(summary);
        }
        public CreditBureauModel Create(Customer customer, bool getFromLog = false, long?logId = null)
        {
            Log.DebugFormat("CreditBureauModel Create customerid: {0} hist: {1} histId: {2}", customer.Id, getFromLog, logId);
            this.tc = new TimeCounter("CreditBureauModel building time for customer " + customer.Stringify());

            var model = new CreditBureauModel {
                Id        = customer.Id,
                Directors = new List <ExperianConsumerModel>()
            };

            using (this.tc.AddStep("Customer {0} total CreditBureauModel time taken", customer.Stringify())) {
                try {
                    using (this.tc.AddStep("GetConsumerInfo for customer time taken")) {
                        model.Consumer = GetConsumerInfo(customer, null, logId, customer.PersonalInfo != null ? customer.PersonalInfo.Fullname : "");
                    }
                    if (customer.Company != null && customer.Company.Directors.Any())
                    {
                        foreach (var director in customer.Company.Directors)
                        {
                            using (this.tc.AddStep("GetConsumerInfo for director {0} time taken", director.Id)) {
                                model.Directors.Add(GetConsumerInfo(customer, director, null,
                                                                    string.Format("{0} {1} {2}", director.Name, director.Middle, director.Surname)));
                            }
                        }
                    }

                    using (this.tc.AddStep("GetAmlInfo time taken")) {
                        model.AmlInfo = GetAmlInfo(customer);
                    }
                    using (this.tc.AddStep("GetBWAInfo time taken")) {
                        model.BavInfo = GetBavInfo(customer);
                    }
                    using (this.tc.AddStep("GetSummaryModel time taken")) {
                        model.Summary = GetSummaryModel(model);
                    }
                } catch (Exception e) {
                    Log.DebugFormat("CreditBureauModel Create Exception {0} ", e);
                    if (model.Consumer != null)
                    {
                        model.Consumer.ErrorList.Add(e.Message);
                    }
                }

                if (model.Consumer != null)
                {
                    model.Consumer.ErrorList.AddRange(Errors);
                }
            }

            Log.Info(this.tc.ToString());

            return(model);
        }