public JsonResult LoadDirector(int directorId) { var director = this.directorRepository.Get(directorId); if (director == null) { throw new Exception(string.Format("director not found id {0}", directorId)); } DirectorModel directorModel = DirectorModel.FromDirector(director, director.Company.Directors.ToList()); return(Json(directorModel, JsonRequestBehavior.AllowGet)); } // LoadDirector
} // 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