示例#1
0
        }         // static constructor

        public CrossCheckModel(int userId, Customer customer)
        {
            Customer = customer;

            Application      = new PersonalInfo();
            EBay             = new PersonalInfo();
            PayPal           = new PersonalInfo();
            EBayAddress      = new CustomerAddress();
            PayPalAddress    = new CustomerAddress();
            SellerAddress    = new CustomerAddress();
            CurrentAddress   = new CustomerAddress();
            PrevAddress      = new CustomerAddress();
            Directors        = new List <Director>();
            CrossCheckStatus = new CrossCheckStatus();

            ExperianDirectors = GetExperianDirectors(customer)
                                .DirectorNames;

            var current = customer
                          .AddressInfo
                          .PersonalAddress
                          .FirstOrDefault(x => x.AddressType == CustomerAddressType.PersonalAddress);

            Zoopla zoopla = null;

            if (current != null)
            {
                zoopla = current.Zoopla.LastOrDefault();
            }

            if (zoopla != null)
            {
                current.ZooplaEstimate      = zoopla.ZooplaEstimate;
                current.ZooplaEstimateValue = zoopla.ZooplaEstimateValue;

                int zooplaValue, experianMortgage, experianMortgageCount;
                GetZooplaData(customer, zoopla.ZooplaEstimateValue, zoopla.AverageSoldPrice1Year, out zooplaValue);
                GetMortgagesData(userId, customer, out experianMortgage, out experianMortgageCount);
                current.ZooplaValue   = zooplaValue;
                ExperianMortgage      = experianMortgage;
                ExperianMortgageCount = experianMortgageCount;

                current.ZooplaUpdateDate = zoopla.UpdateDate;
                current.ZooplaAverage    = zoopla.AverageSoldPrice1Year.ToString("N0");

                AssetWorth = current.ZooplaValue - ExperianMortgage;
            }
            var prev = customer
                       .AddressInfo
                       .PrevPersonAddresses
                       .OrderByDescending(x => x.AddressId)
                       .FirstOrDefault(x => x.AddressType == CustomerAddressType.PrevPersonAddresses);

            CurrentAddress = current;
            if (prev != null)
            {
                PrevAddress = prev;
            }
            if (customer.PersonalInfo != null)
            {
                Application       = Mapper.Map <EZBob.DatabaseLib.Model.Database.PersonalInfo, PersonalInfo>(customer.PersonalInfo);
                Application.Email = customer.Name;
            }

            if (customer.PropertyStatus != null)
            {
                PropertyStatus = new PropertyStatusModel {
                    Id                       = customer.PropertyStatus.Id,
                    Description              = customer.PropertyStatus.Description,
                    IsOwnerOfMainAddress     = customer.PropertyStatus.IsOwnerOfMainAddress,
                    IsOwnerOfOtherProperties = customer.PropertyStatus.IsOwnerOfOtherProperties
                };
            }

            var ebay = customer.GetEbayCustomerMarketPlaces()
                       .FirstOrDefault();

            if (ebay != null)
            {
                var eBayUserData = ebay.EbayUserData.LastOrDefault();
                if (eBayUserData != null)
                {
                    EBay = Mapper.Map <MP_EbayUserData, PersonalInfo>(eBayUserData);
                    if (EBay.SellerInfo.SellerPaymentAddress != null)
                    {
                        SellerAddress = Mapper.Map <MP_EbayUserAddressData, CustomerAddress>(EBay.SellerInfo.SellerPaymentAddress);
                    }
                    if (eBayUserData.RegistrationAddress != null)
                    {
                        EBayAddress = Mapper.Map <MP_EbayUserAddressData, CustomerAddress>(eBayUserData.RegistrationAddress);
                    }
                }
                if (eBayUserData != null && eBayUserData.RegistrationAddress != null)
                {
                    EBay.Fullname     = eBayUserData.RegistrationAddress.Name;
                    EBay.DaytimePhone = eBayUserData.RegistrationAddress.Phone;
                    EBay.MobilePhone  = eBayUserData.RegistrationAddress.Phone2;
                }
            }
            var paypal = customer.GetPayPalCustomerMarketPlaces()
                         .FirstOrDefault();

            if (paypal != null)
            {
                PayPal        = Mapper.Map <MP_PayPalPersonalInfo, PersonalInfo>(paypal.PersonalInfo);
                PayPalAddress = Mapper.Map <MP_PayPalPersonalInfo, CustomerAddress>(paypal.PersonalInfo);
            }

            if (customer.Company != null)
            {
                Directors.AddRange(customer.Company.Directors.Where(x => !x.IsDeleted));
            }

            CrossCheckStatus.BuildMarkerStatusForPersonalInfo(Application, PayPal, EBay);
            CrossCheckStatus.BuildMarkerStatusForCustomerAddress(CurrentAddress, EBayAddress, PayPalAddress);
        }         // constructor
示例#2
0
        }         // 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