public JsonResult Iovation(string blackbox, string origin) { var ip = RemoteIp(); var customer = this.context.Customer; if (customer == null) { log.Info("Iovation black box {0} ip {1} customer is null", blackbox, ip); return(Json(new { })); } // if var request = new IovationCheckModel { CustomerID = customer.Id, AccountCode = customer.RefNumber, BeginBlackBox = blackbox, Email = customer.Name, EndUserIp = ip, MobilePhoneNumber = customer.PersonalInfo != null ? customer.PersonalInfo.MobilePhone : string.Empty, Origin = origin, Type = "application", mobilePhoneVerified = customer.PersonalInfo != null && customer.PersonalInfo.MobilePhoneVerified, mobilePhoneSmsEnabled = customer.PersonalInfo != null && customer.PersonalInfo.MobilePhoneVerified }; if (customer.WizardStep.TheLastOne) { var address = customer.AddressInfo.PersonalAddress.FirstOrDefault(); request.MoreData = new IovationCheckMoreDataModel { BillingCity = address == null ? "" : address.Town, BillingPostalCode = address == null ? "" : address.Postcode, BillingCountry = address == null ? "" : address.Country, BillingStreet = address == null ? "" : address.Line1, FirstName = customer.PersonalInfo == null ? "" : customer.PersonalInfo.FirstName, LastName = customer.PersonalInfo == null ? "" : customer.PersonalInfo.Surname, HomePhoneNumber = customer.PersonalInfo == null ? "" : customer.PersonalInfo.DaytimePhone, EmailVerified = EmailConfirmationState.IsVerified(customer), }; } // if this.serviceClient.Instance.IovationCheck(request); log.Info("Iovation black box {0} ip {1} customer {2}, origin {3}", blackbox, ip, customer.Id, origin); return(Json(new { })); } // Iovation
} // constructor public WizardModel BuildWizardModel( Customer cus, HttpSessionStateBase session, string profile, string requestUrl, bool isProfile ) { CustomerOrigin uiOrigin = cus == null?UiCustomerOrigin.Get() : cus.CustomerOrigin; var wizardModel = new WizardModel(); Log.InfoFormat( "BuildWizardModel URL: {0} origin {1} customer {2}", requestUrl, uiOrigin.Name, cus == null ? "null" : cus.Id.ToString() ); var customerModel = new CustomerModel { loggedIn = cus != null, bankAccountAdded = false, Origin = uiOrigin.Name, }; if (!string.IsNullOrEmpty(profile)) { wizardModel.WhiteLabel = _whiteLabelProviderRepository.GetByName(profile); customerModel.IsWhiteLabel = wizardModel.WhiteLabel != null; customerModel.WhiteLabelId = wizardModel.WhiteLabel != null ? wizardModel.WhiteLabel.Id : 0; } wizardModel.Customer = customerModel; if (!customerModel.loggedIn) { customerModel.IsBrokerFill = (session[Constant.Broker.FillsForCustomer] ?? Constant.No).ToString() == Constant.Yes; return(wizardModel); } // if if (cus == null) { return(wizardModel); } var customer = m_oCustomerRepository.GetAndInitialize(cus.Id); if (customer == null) { return(wizardModel); } var user = m_oUsers.Get(cus.Id); customerModel.Origin = customer.CustomerOrigin.Name; customerModel.IsTest = customer.IsTest; if (customer.WhiteLabel != null) { wizardModel.WhiteLabel = customer.WhiteLabel; customerModel.IsWhiteLabel = wizardModel.WhiteLabel != null; customerModel.WhiteLabelId = customer.WhiteLabel.Id; } // if customerModel.Id = customer.Id; customerModel.RefNumber = customer.RefNumber; customerModel.userName = user.Name; customerModel.Email = customer.Name; customerModel.EmailState = EmailConfirmationState.Get(customer); customerModel.CustomerPersonalInfo = customer.PersonalInfo; customerModel.IsAlibaba = customer.IsAlibaba; if (customer.PropertyStatus != null) { customerModel.PropertyStatus = new PropertyStatusModel { Id = customer.PropertyStatus.Id, Description = customer.PropertyStatus.Description, IsOwnerOfOtherProperties = customer.PropertyStatus.IsOwnerOfOtherProperties, IsOwnerOfMainAddress = customer.PropertyStatus.IsOwnerOfMainAddress }; } else { customerModel.PropertyStatus = new PropertyStatusModel(); } // if customerModel.BusinessTypeReduced = customerModel.CustomerPersonalInfo == null? TypeOfBusinessReduced.Personal.ToString() : customer.PersonalInfo.TypeOfBusiness.Reduce().ToString(); customerModel.mpAccounts = customer.GetMarketPlaces(); customerModel.CreditSum = customer.CreditSum; customerModel.CreditResult = customer.CreditResult.ToString(); customerModel.Status = customer.Status.ToString(); var account = new AccountSettingsModel { SecurityQuestions = m_oQuestions.GetQuestions(), SecurityQuestionModel = new SecurityQuestionModel { Question = user.SecurityQuestion == null ? 0 : user.SecurityQuestion.Id, Answer = user.SecurityAnswer }, }; customerModel.AccountSettings = account; customerModel.GreetingMailSentDate = customer.GreetingMailSentDate; var company = customer.Company; customerModel.CanHaveDirectors = false; if (company != null) { customerModel.CanHaveDirectors = company.TypeOfBusiness != TypeOfBusiness.SoleTrader; customerModel.CompanyInfo = CompanyInfoMap.FromCompany(company); customerModel.CompanyAddress = company.CompanyAddress.ToArray(); customerModel.CompanyInfo.Directors.AddRange( m_oExperianDirectors.Find(customer.Id) .Select(ed => DirectorModel.FromExperianDirector(ed, company.TypeOfBusiness.Reduce())) ); } // if if (customer.AddressInfo != null) { customerModel.PersonalAddress = customer.AddressInfo.PersonalAddress.ToArray(); customerModel.PrevPersonAddresses = customer.AddressInfo.PrevPersonAddresses.ToArray(); customerModel.OtherPropertiesAddresses = customer.AddressInfo.OtherPropertiesAddresses.ToArray(); } // if customerModel.CompanyEmployeeCountInfo = new CompanyEmployeeCountInfo(customer.Company); customerModel.CustomerStatusName = customer.CollectionStatus.Name; // customerModel.LoyaltyPoints = customer.LoyaltyPoints(); customerModel.IsOffline = customer.IsOffline; customerModel.IsDisabled = !customer.CollectionStatus.IsEnabled; customerModel.LastSavedWizardStep = ((customer.WizardStep == null) || customer.WizardStep.TheLastOne) ? string.Empty : customer.WizardStep.Name; customerModel.QuickOffer = BuildQuickOfferModel(customer); CustomerRequestedLoan ra = customer.CustomerRequestedLoan.OrderByDescending(x => x.Created).FirstOrDefault(); customerModel.RequestedLoan = ra ?? new CustomerRequestedLoan(); customerModel.IsBrokerFill = customer.FilledByBroker; customerModel.DefaultCardSelectionAllowed = customer.DefaultCardSelectionAllowed; var cr = customer.LastCashRequest; customerModel.IsCurrentCashRequestFromQuickOffer = (cr != null) && (cr.QuickOffer != null); customerModel.IsLoanDetailsFixed = !m_oChangeLoanDetailsModelBuilder.IsAmountChangingAllowed(cr); customerModel.LastCashRequestID = (cr == null) ? 0 : cr.Id; if (isProfile) { BuildProfileModel(customerModel, customer); } return(wizardModel); } // BuildWizardModel
} // constructor public void InitFromCustomer(Customer customer) { if (customer == null) { return; } IsBrokerRegulated = (customer.Broker != null) && customer.Broker.FCARegistered; IsWizardComplete = (customer.WizardStep != null) && customer.WizardStep.TheLastOne; Id = customer.Id; SegmentType = customer.SegmentType(); Origin = customer.CustomerOrigin.Name; IsAvoid = customer.IsAvoid; IsAlibaba = customer.IsAlibaba; FraudCheckStatus = customer.FraudStatus.Description(); FraudCheckStatusId = (int)customer.FraudStatus; Website = "www." + customer.Name.Substring(customer.Name.IndexOf('@') + 1); if (customer.PersonalInfo != null) { IsRegulated = customer.PersonalInfo.IsRegulated; if (customer.PersonalInfo.DateOfBirth.HasValue) { DateOfBirth = customer.PersonalInfo.DateOfBirth.Value; Age = MiscUtils.GetFullYears(customer.PersonalInfo.DateOfBirth.Value); Gender = customer.PersonalInfo.Gender.ToString(); FullGender = Gender == "M" ? "Male" : "Female"; FamilyStatus = customer.PersonalInfo.MaritalStatus.ToString(); if (customer.PropertyStatus != null) { PropertyStatus = new PropertyStatusModel { Description = customer.PropertyStatus.Description, Id = customer.PropertyStatus.Id, IsOwnerOfMainAddress = customer.PropertyStatus.IsOwnerOfMainAddress, IsOwnerOfOtherProperties = customer.PropertyStatus.IsOwnerOfOtherProperties }; } } } if (customer.Company != null) { CompanyName = customer.Company.CompanyName; CompanyType = customer.Company.TypeOfBusiness.ToString(); CompanyExperianRefNum = customer.Company.ExperianRefNum; if (customer.Company.Directors != null) { List <Director> oDirList = customer.Company.Directors.Where(x => !x.IsDeleted).ToList(); if (oDirList.Count > 0) { Directors = customer.Company.Directors.Select(d => DirectorModel.FromDirector(d, oDirList)).ToArray(); } } // if } // if if (Directors == null) { Directors = new DirectorModel[0]; } if (customer.FraudStatus != FraudStatus.Ok) { IsFraudInAlertMode = true; } IsTestInAlertMode = customer.IsTest; AmlResult = customer.AMLResult; IsAmlInAlertMode = AmlResult != "Passed"; PromoCode = customer.PromoCode; if (!string.IsNullOrEmpty(PromoCode)) { PromoCodeCss = "promo_code"; } if (customer.PersonalInfo != null) { Name = customer.PersonalInfo.Fullname; FirstName = customer.PersonalInfo.FirstName; Surname = customer.PersonalInfo.Surname; MobilePhone = customer.PersonalInfo.MobilePhone; DaytimePhone = customer.PersonalInfo.DaytimePhone; OverallTurnOver = customer.PersonalInfo.OverallTurnOver; WebSiteTurnOver = customer.PersonalInfo.WebSiteTurnOver; } // if List <CustomerPhone> customerPhones = customerPhoneRepository .GetAll() .Where(x => x.CustomerId == customer.Id && x.IsCurrent) .ToList(); MobileTooltip = "Click to verify"; DaytimeTooltip = "Click to verify"; foreach (CustomerPhone customerPhone in customerPhones) { if (customerPhone.PhoneType == "Mobile") { MobilePhoneVerified = customerPhone.IsVerified; if (MobilePhoneVerified) { if (!string.IsNullOrEmpty(customerPhone.VerifiedBy) && customerPhone.VerificationDate.HasValue) { MobileTooltip = string.Format("Verified by {0} at {1}", customerPhone.VerifiedBy, customerPhone.VerificationDate.Value.ToShortDateString()); } else { MobileTooltip = "Verified"; } } } else if (customerPhone.PhoneType == "Daytime") { DaytimePhoneVerified = customerPhone.IsVerified; if (DaytimePhoneVerified) { if (!string.IsNullOrEmpty(customerPhone.VerifiedBy) && customerPhone.VerificationDate.HasValue) { DaytimeTooltip = string.Format("Verified by {0} at {1}", customerPhone.VerifiedBy, customerPhone.VerificationDate.Value.ToShortDateString()); } else { DaytimeTooltip = "Verified"; } } } } Medal = customer.Medal.HasValue ? customer.Medal.ToString() : ""; Email = customer.Name; EmailState = EmailConfirmationState.Get(customer); if (customer.GreetingMailSentDate != null) { DateTime registrationDate = customer.GreetingMailSentDate.Value; int registrationTimeYears, registrationTimeMonths; MiscUtils.GetFullYearsAndMonths(registrationDate, out registrationTimeYears, out registrationTimeMonths); RegistrationDate = customer.GreetingMailSentDate.Value.ToString("MMM dd, yyyy") + string.Format(" [{0}y {1}m]", registrationTimeYears, registrationTimeMonths); } UserStatus = customer.Status.ToString(); CreditResult = customer.CreditResult.ToString(); CustomerStatusId = customer.CollectionStatus.Id; IsCustomerInEnabledStatus = customer.CollectionStatus.IsEnabled; IsCustomerStatusInAlertMode = customer.CollectionStatus.Name != "Enabled"; CustomerStatusName = customer.CollectionStatus.Name; IsWarning = customer.CollectionStatus.IsWarning; ReferenceSource = customer.ReferenceSource; ABTesting = customer.ABTesting; CompanyEmployeeCountInfo = new CompanyEmployeeCountInfo(customer.Company); ActiveCampaign = ""; var activeCampaigns = customer.ActiveCampaigns .Where(cc => cc.Campaign.EndDate >= DateTime.Today && cc.Campaign.StartDate <= DateTime.Today ) .Select(cc => cc.Campaign.Name) .ToList(); if (activeCampaigns.Any()) { ActiveCampaign = activeCampaigns.Aggregate((i, j) => i + ", " + j); } IsCciMarkInAlertMode = customer.CciMark; BlockTakingLoan = customer.BlockTakingLoan; TrustPilotStatusDescription = customer.TrustPilotStatus.Description; TrustPilotStatusName = customer.TrustPilotStatus.Name; ExternalCollectionStatusName = customer.ExternalCollectionStatus == null ? "" : customer.ExternalCollectionStatus.Name; ExternalCollectionStatusID = customer.ExternalCollectionStatus == null ? "" : Convert.ToString(customer.ExternalCollectionStatus.Id); BrokerID = customer.Broker == null ? 0 : customer.Broker.ID; BrokerName = customer.Broker == null ? "" : customer.Broker.ContactName; BrokerFirmName = customer.Broker == null ? "" : customer.Broker.FirmName; BrokerContactEmail = customer.Broker == null ? "" : customer.Broker.ContactEmail; BrokerContactMobile = customer.Broker == null ? "" : customer.Broker.ContactMobile; CustomerAddress oAddress = customer.AddressInfo.PersonalAddress.FirstOrDefault(); if (oAddress != null) { PostCode = oAddress.Rawpostcode; } DbConnectionGenerator.Get(new SafeILog(this)).ForEachRowSafe( sr => { switch ((string)sr["DocumentName"]) { case "Board resolution": BoardResolutionTemplateID = sr["EsignTemplateID"]; break; case "Personal guarantee": PersonalGuaranteeTemplateID = sr["EsignTemplateID"]; break; } // switch }, "LoadEsignTemplatesByCustomer", CommandSpecies.StoredProcedure, new QueryParameter("CustomerID", customer.Id) ); } // InitFromCustomer