示例#1
0
        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);
        }
        }         // GetLastTransaction

        protected override void InitializeSpecificData(
            MP_CustomerMarketPlace mp,
            MarketPlaceModel model,
            DateTime?history
            )
        {
            TimeCounter tc = new TimeCounter("MarketplaceModelBuilder Amazon InitializeSpecificData building time for mp " + mp.Id);

            using (tc.AddStep("AskvilleStatus Time taken")) {
                var askville    = ObjectFactory.GetInstance <AskvilleRepository>();
                var askvilleTmp = askville.GetAskvilleByMarketplace(mp);

                model.AskvilleStatus = askvilleTmp != null
                                        ? askvilleTmp.Status.ToString()
                                        : AskvilleStatus.NotPerformed.ToString();

                model.AskvilleGuid = askvilleTmp != null ? askvilleTmp.Guid : "";
            }
            using (tc.AddStep("GetAmazonCategories Time taken")) {
                model.Categories = GetAmazonCategories(mp);
            }

            Log.Info(tc.ToString());
        }         // InitializeSpecificData
示例#3
0
        }         // LoadGrid

        private ContentResult LoadGrid(
            GridActions nSpName,
            bool bIncludeTestCustomers,
            Func <AGridRow> oFactory,
            bool?bIncludeAllCustomers,
            DateTime?now = null,
            IEnumerable <QueryParameter> oMoreSpArgs = null
            )
        {
            TimeCounter tc   = new TimeCounter("LoadGrid building time for grid " + nSpName);
            var         oRes = new SortedDictionary <long, AGridRow>();


            var args = new List <QueryParameter> {
                new QueryParameter("@WithTest", bIncludeTestCustomers),
            };

            if (bIncludeAllCustomers.HasValue)
            {
                args.Add(new QueryParameter("@WithAll", bIncludeAllCustomers));
            }

            if (now.HasValue)
            {
                args.Add(new QueryParameter("@Now", now.Value));
            }

            if (oMoreSpArgs != null)
            {
                args.AddRange(oMoreSpArgs);
            }



            using (tc.AddStep("retrieving from db and processing")) {
                this.db.ForEachRowSafe(
                    sr => {
                    AGridRow r = oFactory();

                    long nRowID = sr[r.RowIDFieldName()];

                    r.Init(nRowID, sr);

                    if (r.IsValid())
                    {
                        oRes[nRowID] = r;
                    }
                },
                    nSpName.ToString(),
                    CommandSpecies.StoredProcedure,
                    args.ToArray()
                    );    // foreach
            }             // using


            log.Debug("{0}: traversing done.", nSpName);

            var sb = new StringBuilder();

            sb.AppendLine(tc.Title);

            foreach (var time in tc.Steps)
            {
                sb.AppendFormat("\t{0}: {1}ms\n", time.Name, time.Length);
            }

            log.Info("{0}", sb);

            var serializer = new JavaScriptSerializer {
                MaxJsonLength = Int32.MaxValue,
            };

            return(new ContentResult {
                Content = serializer.Serialize(new { aaData = oRes.Values }),
                ContentType = "application/json",
            });
        }         // LoadGrid
示例#4
0
        }         // BuildMultiBrandAlert

        private void BuildAlerts(ProfileSummaryModel summary, Customer customer)
        {
            TimeCounter tc = new TimeCounter("BuildAlerts building time for customer " + customer.Id);

            summary.Alerts = new AlertsModel {
                Errors   = new List <AlertModel>(),
                Warnings = new List <AlertModel>(),
                Infos    = new List <AlertModel>(),
            };

            using (tc.AddStep("BuildMultiBrandAlert Time taken")) {
                BuildMultiBrandAlert(customer.Id, summary.Alerts);
            }

            using (tc.AddStep("CustomerAlerts Time taken")) {
                var isBrokerRegulated = (customer.Broker != null) && customer.Broker.FCARegistered;

                var IsWizardComplete = (customer.WizardStep != null) && customer.WizardStep.TheLastOne;

                if (!isBrokerRegulated && customer.PersonalInfo.IsRegulated && IsWizardComplete)
                {
                    summary.Alerts.Infos.Add(new AlertModel {
                        Abbreviation = "NRB",
                        Alert        = "Regulated customer for a Non-Regulated broker",
                        AlertType    = AlertType.Warning.DescriptionAttr(),
                        Tab          = ProfileTab.Dashboard.DescriptionAttr()
                    });
                }                 // if

                if (customer.IsTest)
                {
                    summary.Alerts.Infos.Add(new AlertModel {
                        Abbreviation = "Test",
                        Alert        = "Is test",
                        AlertType    = AlertType.Info.DescriptionAttr(),
                        Tab          = ProfileTab.Dashboard.DescriptionAttr()
                    });
                }                 // if

                if (customer.IsAlibaba)
                {
                    summary.Alerts.Infos.Add(new AlertModel {
                        Abbreviation = "Ali",
                        Alert        = "Is alibaba customer",
                        AlertType    = AlertType.Info.DescriptionAttr(),
                        Tab          = ProfileTab.Dashboard.DescriptionAttr()
                    });
                }                 // if

                if (customer.CciMark)
                {
                    summary.Alerts.Errors.Add(new AlertModel {
                        Abbreviation = "CCI",
                        Alert        = "CCI Mark",
                        AlertType    = AlertType.Error.DescriptionAttr(),
                        Tab          = ProfileTab.Dashboard.DescriptionAttr()
                    });
                }                 // if

                if (customer.CollectionStatus.IsDefault || customer.CollectionStatus.Name == "Bad")
                {
                    summary.Alerts.Errors.Add(new AlertModel {
                        Abbreviation = "Bad",
                        Alert        = string.Format("Customer Status : {0}", customer.CollectionStatus.Name),
                        AlertType    = AlertType.Error.DescriptionAttr(),
                        Tab          = ProfileTab.Dashboard.DescriptionAttr()
                    });
                }
                else if (customer.CollectionStatus.Name == "Risky")
                {
                    summary.Alerts.Warnings.Add(new AlertModel {
                        Abbreviation = "Risky",
                        Alert        = string.Format("Customer Status : {0}", customer.CollectionStatus.Name),
                        AlertType    = AlertType.Warning.DescriptionAttr(),
                        Tab          = ProfileTab.Dashboard.DescriptionAttr()
                    });
                }                 // if

                if (customer.FraudStatus != FraudStatus.Ok)
                {
                    summary.Alerts.Errors.Add(new AlertModel {
                        Abbreviation = "F",
                        Alert        = string.Format("Fraud Status : {0}", customer.FraudStatus.DescriptionAttr()),
                        AlertType    = AlertType.Error.DescriptionAttr(),
                        Tab          = ProfileTab.FraudDetection.DescriptionAttr()
                    });
                }                 // if

                if (customer.CreditResult == CreditResultStatus.PendingInvestor)
                {
                    summary.Alerts.Warnings.Add(new AlertModel {
                        Abbreviation = "PI",
                        Alert        = string.Format("Credit Result : {0}", customer.CreditResult.DescriptionAttr()),
                        AlertType    = AlertType.Warning.DescriptionAttr(),
                        Tab          = ProfileTab.Dashboard.DescriptionAttr()
                    });
                }                 // if

                switch (customer.AMLResult)
                {
                case "Rejected":
                    summary.Alerts.Errors.Add(new AlertModel {
                        Abbreviation = "AML",
                        Alert        = string.Format("AML Status : {0}", customer.AMLResult),
                        AlertType    = AlertType.Error.DescriptionAttr(),
                        Tab          = ProfileTab.CreditBureau.DescriptionAttr()
                    });
                    break;

                case "Not performed":
                case "Warning":
                    summary.Alerts.Warnings.Add(new AlertModel {
                        Abbreviation = "AML",
                        Alert        = string.Format("AML Status : {0}", customer.AMLResult),
                        AlertType    = AlertType.Warning.DescriptionAttr(),
                        Tab          = ProfileTab.CreditBureau.DescriptionAttr()
                    });
                    break;
                }                 // switch

                switch (summary.CreditBureau.ThinFile)
                {
                case "Yes":
                    summary.Alerts.Errors.Add(new AlertModel {
                        Abbreviation = "TF",
                        Alert        = "Thin file",
                        AlertType    = AlertType.Error.DescriptionAttr(),
                        Tab          = ProfileTab.CreditBureau.DescriptionAttr()
                    });
                    break;

                case "N/A":
                    summary.Alerts.Warnings.Add(new AlertModel {
                        Abbreviation = "N/A",
                        Alert        = "Couldn't get financial accounts",
                        AlertType    = AlertType.Warning.DescriptionAttr(),
                        Tab          = ProfileTab.Dashboard.DescriptionAttr()
                    });
                    break;
                }                 // switch

                if (summary.CreditBureau.NumDirectorThinFiles > 0)
                {
                    summary.Alerts.Errors.Add(new AlertModel {
                        Abbreviation = "TF",
                        Alert        =
                            string.Format("{0} director{1} with thin file", summary.CreditBureau.NumDirectorThinFiles,
                                          summary.CreditBureau.NumDirectorThinFiles == 1 ? "" : "s"),
                        AlertType = AlertType.Error.DescriptionAttr(),
                        Tab       = ProfileTab.Dashboard.DescriptionAttr()
                    });
                }                 // if

                if (summary.CreditBureau.NumDirectorNA > 0)
                {
                    summary.Alerts.Warnings.Add(new AlertModel {
                        Abbreviation = "N/A",
                        Alert        =
                            string.Format("{0} director{1} with no experian data available", summary.CreditBureau.NumDirectorNA,
                                          summary.CreditBureau.NumDirectorThinFiles == 1 ? "" : "s"),
                        AlertType = AlertType.Warning.DescriptionAttr(),
                        Tab       = ProfileTab.Dashboard.DescriptionAttr()
                    });
                }                 // if

                if (summary.CreditBureau.ApplicantDOBs != null)
                {
                    foreach (var dob in summary.CreditBureau.ApplicantDOBs)
                    {
                        if (dob.HasValue && (dob.Value.AddYears(18) > DateTime.Today))
                        {
                            summary.Alerts.Errors.Add(new AlertModel {
                                Abbreviation = "A",
                                Alert        = "Age of applicant under 18",
                                AlertType    = AlertType.Error.DescriptionAttr(),
                                Tab          = ProfileTab.Dashboard.DescriptionAttr()
                            });
                        }         // if
                    }             // for each
                }                 // if

                if (customer.CustomerRelationStates.Any())
                {
                    var state = customer.CustomerRelationStates.First();
                    if (state.IsFollowUp.HasValue && state.IsFollowUp.Value && state.FollowUp.FollowUpDate <= DateTime.UtcNow)
                    {
                        summary.Alerts.Errors.Add(new AlertModel {
                            Abbreviation = "Follow",
                            Alert        = "Customer relations follow up date is due " + state.FollowUp.FollowUpDate.ToString("dd/MM/yyyy"),
                            AlertType    = AlertType.Error.DescriptionAttr(),
                            Tab          = ProfileTab.CustomerRelations.DescriptionAttr()
                        });
                    }             // if
                }                 // if
            }

            using (tc.AddStep("GetCompanySeniorityAlerts Time taken")) {
                try {
                    if (customer.PersonalInfo != null)
                    {
                        DateTime?companySeniority =
                            this.serviceClient.Instance.GetCompanySeniority(customer.Id,
                                                                            customer.PersonalInfo.TypeOfBusiness.Reduce() ==
                                                                            TypeOfBusinessReduced.Limited, this.context.UserId)
                            .Value;
                        if (companySeniority.HasValue && companySeniority.Value.AddYears(1) > DateTime.UtcNow &&
                            (companySeniority.Value.Year != DateTime.UtcNow.Year || companySeniority.Value.Month != DateTime.UtcNow.Month ||
                             companySeniority.Value.Day != DateTime.UtcNow.Day))
                        {
                            summary.Alerts.Errors.Add(new AlertModel {
                                Abbreviation = "YC",
                                Alert        = "Young company. Incorporation date: " + companySeniority.Value.ToString("dd/MM/yyyy"),
                                AlertType    = AlertType.Error.DescriptionAttr(),
                                Tab          = ProfileTab.CompanyScore.DescriptionAttr()
                            });
                        }
                    }
                } catch (Exception e) {
                    log.Debug(e, "Error fetching company seniority.");
                }                 // try
            }
            using (tc.AddStep("BuildLandRegistryAlerts Time taken")) {
                bool bResult = BuildLandRegistryAlerts(customer, summary);
                log.Debug("Just FYI: BuildLandRegistryAlerts() returned {0}", bResult ? "true" : "false");
            }
            using (tc.AddStep("BuildDataAlerts Time taken")) {
                BuildDataAlerts(customer, summary);
            }
            using (tc.AddStep("BuildCompanyCaisAlerts Time taken")) {
                BuildCompanyCaisAlerts(customer, summary, this.context.UserId);
            }
            using (tc.AddStep("LoadExperianConsumerMortgageData Time taken")) {
                bool hasMortgage = false;
                bool isHomeOwner = customer.PropertyStatus != null && (customer.PropertyStatus.IsOwnerOfMainAddress || customer.PropertyStatus.IsOwnerOfOtherProperties);
                try {
                    hasMortgage = this.serviceClient.Instance.LoadExperianConsumerMortgageData(this.context.UserId, customer.Id)
                                  .Value.NumMortgages > 0;
                } catch (Exception e) {
                    log.Debug(e, "Error fetching customer's mortgages.");
                }                 // try

                if (isHomeOwner && !hasMortgage)
                {
                    summary.Alerts.Warnings.Add(new AlertModel {
                        Abbreviation = "MTG",
                        Alert        = "Home owner and no mortgages",
                        AlertType    = AlertType.Warning.DescriptionAttr(),
                        Tab          = ProfileTab.Properties.DescriptionAttr()
                    });
                }
                else if (!isHomeOwner && hasMortgage)
                {
                    summary.Alerts.Warnings.Add(new AlertModel {
                        Abbreviation = "MTG",
                        Alert        = "Has mortgages but not a home owner",
                        AlertType    = AlertType.Warning.DescriptionAttr(),
                        Tab          = ProfileTab.Properties.DescriptionAttr()
                    });
                }                 // if
            }
            using (tc.AddStep("MedalAlerts Time taken")) {
                this.medalCalculationsRepository = ObjectFactory.GetInstance <MedalCalculationsRepository>();
                MedalCalculations medalCalculationsRecord = this.medalCalculationsRepository.GetActiveMedal(customer.Id);

                if (customer.Company != null && (customer.Company.TypeOfBusiness == EZBob.DatabaseLib.Model.Database.TypeOfBusiness.LLP || customer.Company.TypeOfBusiness == EZBob.DatabaseLib.Model.Database.TypeOfBusiness.Limited) && customer.CustomerMarketPlaces.Count(x => x.Marketplace.Name == "HMRC") < 2)
                {
                    // The customer should have medal
                    if (medalCalculationsRecord == null)
                    {
                        summary.Alerts.Errors.Add(new AlertModel {
                            Abbreviation = "MDL",
                            Alert        = "New medal was not calculated",
                            AlertType    = AlertType.Error.DescriptionAttr(),
                            Tab          = ProfileTab.Calculator.DescriptionAttr()
                        });
                    }
                    else if (!string.IsNullOrEmpty(medalCalculationsRecord.Error))
                    {
                        summary.Alerts.Errors.Add(new AlertModel {
                            Abbreviation = "MDL",
                            Alert        = string.Format("Error while calculating new medal: {0}", medalCalculationsRecord.Error),
                            AlertType    = AlertType.Error.DescriptionAttr(),
                            Tab          = ProfileTab.Calculator.DescriptionAttr()
                        });
                    }                     // if
                }
                else if (customer.Company != null && (customer.Company.TypeOfBusiness != EZBob.DatabaseLib.Model.Database.TypeOfBusiness.LLP &&
                                                      customer.Company.TypeOfBusiness != EZBob.DatabaseLib.Model.Database.TypeOfBusiness.Limited) ||
                         customer.CustomerMarketPlaces.Count(x => x.Marketplace.Name == "HMRC") > 1)
                {
                    summary.Alerts.Infos.Add(new AlertModel {
                        Abbreviation = "MDL",
                        Alert        = "This customer shouldn't have new medal",
                        AlertType    = AlertType.Info.DescriptionAttr(),
                        Tab          = ProfileTab.Calculator.DescriptionAttr()
                    });
                } // if
            }     //MedalAlerts
            log.Info(tc.ToString());
        }         // BuildAlerts
示例#5
0
        public JsonResult Index(int id)
        {
            log.Debug("Build full customer model begin for customer {0}", id);

            var model = new FullCustomerModel();

            var customer = this.customerRepo.ReallyTryGet(id);

            if (customer == null)
            {
                model.State = "NotFound";
                return(Json(model, JsonRequestBehavior.AllowGet));
            }             // if

            TimeCounter tc = new TimeCounter("FullCustomerModel building time for customer " + customer.Stringify());

            using (tc.AddStep("Customer {0} total FullCustomerModel time taken", customer.Stringify())) {
                var cr = customer.LastCashRequest;

                using (tc.AddStep("PersonalInfoModel Time taken")) {
                    var pi = new PersonalInfoModel();
                    pi.InitFromCustomer(customer);
                    model.PersonalInfoModel = pi;
                }                 // using

                using (tc.AddStep("ApplicationInfoModel Time taken")) {
                    try {
                        var aiar = this.serviceClient.Instance.LoadApplicationInfo(
                            this.context.UserId,
                            customer.Id,
                            cr == null ? (long?)null : cr.Id,
                            DateTime.UtcNow
                            );

                        model.ApplicationInfoModel = aiar.Model;
                    } catch (Exception ex) {
                        log.Error(ex, "Failed to load application info model for customer {0} cr {1}", customer.Id, cr == null ? (long?)null : cr.Id);
                    }
                }                 // using

                using (tc.AddStep("CreditBureauModel Time taken"))
                    model.CreditBureauModel = this.creditBureauModelBuilder.Create(customer);

                using (tc.AddStep("CompanyScore Time taken")) {
                    var builder = new CompanyScoreModelBuilder();
                    model.CompanyScore = builder.Create(customer);

                    DateTime?companySeniority = model.CompanyScore.DashboardModel.OriginationDate;
                    int      companySeniorityYears = 0, companySeniorityMonths = 0;
                    if (companySeniority.HasValue)
                    {
                        MiscUtils.GetFullYearsAndMonths(
                            companySeniority.Value,
                            out companySeniorityYears,
                            out companySeniorityMonths
                            );
                    }                     // if

                    model.PersonalInfoModel.CompanySeniority = string.Format(
                        "{0}y {1}m",
                        companySeniorityYears,
                        companySeniorityMonths
                        );

                    model.PersonalInfoModel.IsYoungCompany =
                        companySeniority.HasValue &&
                        companySeniority.Value.AddYears(1) > DateTime.UtcNow && (
                            companySeniority.Value.Year != DateTime.UtcNow.Year ||
                            companySeniority.Value.Month != DateTime.UtcNow.Month ||
                            companySeniority.Value.Day != DateTime.UtcNow.Day
                            );
                }                 // using

                using (tc.AddStep("SummaryModel Time taken"))
                    model.SummaryModel = this.summaryModelBuilder.CreateProfile(customer, model.CreditBureauModel, model.CompanyScore);

                using (tc.AddStep("MedalCalculations Time taken"))
                    model.MedalCalculations = new MedalCalculators(customer);

                using (tc.AddStep("PropertiesModel Time taken"))
                    model.Properties = this.propertiesModelBuilder.Create(customer);

                using (tc.AddStep("CustomerRelations Time taken")) {
                    var crm = new CustomerRelationsModelBuilder(
                        this.loanRepo,
                        this.customerRelationsRepo,
                        this.session
                        );
                    model.CustomerRelations = crm.Create(customer.Id);
                }                 // using

                using (tc.AddStep("Bugs Time taken")) {
                    model.Bugs = this.bugRepo
                                 .GetAll()
                                 .Where(x => x.Customer.Id == customer.Id)
                                 .Select(x => BugModel.ToModel(x))
                                 .ToList();
                }                 // using



                using (tc.AddStep("ExperianDirectors Time taken")) {
                    var expDirModel = CrossCheckModel.GetExperianDirectors(customer);
                    model.ExperianDirectors = expDirModel.DirectorNames;
                    model.PersonalInfoModel.NumOfDirectors    = expDirModel.NumOfDirectors;
                    model.PersonalInfoModel.NumOfShareholders = expDirModel.NumOfShareHolders;
                }                 // using

                model.State = "Ok";
            }             // using "Total" step

            log.Info(tc.ToString());

            log.Debug("Build full customer model end for customer {0}", id);

            return(Json(model, JsonRequestBehavior.AllowGet));
        }         // Index
        }         // constructor

        public MarketPlaceModel Create(MP_CustomerMarketPlace mp, DateTime?history)
        {
            string      lastChecked         = "";
            string      updatingStatus      = "";
            string      updatingError       = "";
            string      age                 = "";
            string      url                 = "";
            DateTime?   lastTransactionDate = null;
            TimeCounter tc = new TimeCounter("MarketplaceModelBuilder building time for mp " + mp.Id);

            using (tc.AddStep("lastChecked Time taken")) {
                lastChecked = mp.UpdatingEnd.HasValue
                                        ? FormattingUtils.FormatDateToString(mp.UpdatingEnd.Value)
                                        : "never/in progress";
            }
            using (tc.AddStep("GetUpdatingStatus Time taken")) {
                updatingStatus = mp.GetUpdatingStatus(history);
            }
            using (tc.AddStep("GetUpdatingError Time taken")) {
                updatingError = mp.GetUpdatingError(history);
            }
            using (tc.AddStep("GetAccountAge Time taken")) {
                DateTime?originationDate;
                age = GetAccountAge(mp, out originationDate);
            }
            using (tc.AddStep("GetUrl Time taken")) {
                url = GetUrl(mp, mp.GetRetrieveDataHelper()
                             .RetrieveCustomerSecurityInfo(mp.Id));
            }
            using (tc.AddStep("GetLastTransactionDate Time taken")) {
                lastTransactionDate = GetLastTransactionDate(mp);
            }

            var model = new MarketPlaceModel {
                Id                  = mp.Id,
                Type                = mp.DisplayName,
                Name                = mp.Marketplace.Name,
                LastChecked         = lastChecked,
                UpdatingStatus      = updatingStatus,
                UpdateError         = updatingError,
                AccountAge          = age,
                PositiveFeedbacks   = 0,
                NegativeFeedbacks   = 0,
                NeutralFeedbacks    = 0,
                RaitingPercent      = 0,
                SellerInfoStoreURL  = url,
                IsPaymentAccount    = mp.Marketplace.IsPaymentAccount,
                UWPriority          = mp.Marketplace.UWPriority,
                Disabled            = mp.Disabled,
                IsNew               = mp.IsNew,
                IsHistory           = history.HasValue,
                History             = history,
                LastTransactionDate = lastTransactionDate,
            };
            List <IAnalysisDataParameterInfo> aggregations = new List <IAnalysisDataParameterInfo>();

            using (tc.AddStep("SetAggregationData Time taken")) {
                aggregations = mp.Marketplace.GetAggregations(mp, history).ToList();
                SetAggregationData(model, aggregations);
            }

            using (tc.AddStep("monthSales Time taken")) {
                var monthSales = aggregations.FirstOrDefault(x =>
                                                             x.TimePeriod.TimePeriodType == TimePeriodEnum.Month &&
                                                             x.ParameterName == AggregationFunction.Turnover.ToString()
                                                             );
                model.MonthSales = monthSales == null ? 0 : (decimal)monthSales.Value;
            }
            using (tc.AddStep("yearSales Time taken")) {
                var yearSales = aggregations.FirstOrDefault(x =>
                                                            x.TimePeriod.TimePeriodType == TimePeriodEnum.Year &&
                                                            x.ParameterName == AggregationFunction.Turnover.ToString()
                                                            );
                model.AnnualSales = yearSales == null ? 0 : (decimal)yearSales.Value;
            }

            using (tc.AddStep("InitializeSpecificData Time taken")) {
                InitializeSpecificData(mp, model, history);
            }
            using (tc.AddStep("GetFeedbackData Time taken")) {
                var feedbacks = GetFeedbackData(aggregations);
                model.RaitingPercent    = feedbacks.RaitingPercent;
                model.PositiveFeedbacks = feedbacks.PositiveFeedbacks;
                model.NegativeFeedbacks = feedbacks.NegativeFeedbacks;
                model.NeutralFeedbacks  = feedbacks.NeutralFeedbacks;
                model.AmazonSelerRating = feedbacks.AmazonSelerRating;
            }

            using (tc.AddStep("GetPaymentAccountModel Time taken")) {
                if (model.IsPaymentAccount)
                {
                    var paymentModel = GetPaymentAccountModel(mp, history, aggregations);
                    model.TotalNetInPayments  = paymentModel.TotalNetInPayments;
                    model.TotalNetOutPayments = paymentModel.TotalNetOutPayments;
                    model.TransactionsNumber  = paymentModel.TransactionsNumber;
                    model.MonthInPayments     = paymentModel.MonthInPayments;
                }                 // if
            }

            Log.Info(tc.ToString());
            return(model);
        }         // Create