示例#1
0
 public string GetEncryptedId()
 {
     return(obfuscator.Obfuscate(OrganisationId.ToString()));
 }
示例#2
0
 public string GetEncryptedId()
 {
     return(Encryption.EncryptQuerystring(OrganisationId.ToString()));
 }
示例#3
0
        public EmployerSearchModel ToEmployerSearchResult(bool keyOnly = false, List <SicCodeSearchModel> listOfSicCodeSearchModels = null)
        {
            if (keyOnly)
            {
                return(new EmployerSearchModel {
                    OrganisationId = OrganisationId.ToString()
                });
            }

            // Get the last two names for the org. Most recent name first
            string[] names = OrganisationNames.Select(n => n.Name).Reverse().Take(2).ToArray();

            var abbreviations = new SortedSet <string>(StringComparer.OrdinalIgnoreCase);

            names.ForEach(n => abbreviations.Add(n.ToAbbr()));
            names.ForEach(n => abbreviations.Add(n.ToAbbr(".")));
            var excludes = new[] { "Ltd", "Limited", "PLC", "Corporation", "Incorporated", "LLP", "The", "And", "&", "For", "Of", "To" };

            names.ForEach(n => abbreviations.Add(n.ToAbbr(excludeWords: excludes)));
            names.ForEach(n => abbreviations.Add(n.ToAbbr(".", excludeWords: excludes)));

            abbreviations.RemoveWhere(a => string.IsNullOrWhiteSpace(a));
            abbreviations.Remove(OrganisationName);

            // extract the prev org name (if exists)
            var prevOrganisationName = "";

            if (names.Length > 1)
            {
                prevOrganisationName = names[names.Length - 1];
                abbreviations.Remove(prevOrganisationName);
            }

            //Get the latest sic codes
            IEnumerable <OrganisationSicCode> sicCodes = GetSicCodes();

            Return[] submittedReports = GetSubmittedReports().ToArray();

            var result = new EmployerSearchModel {
                OrganisationId          = OrganisationId.ToString(),
                OrganisationIdEncrypted = GetEncryptedId(),
                Name         = OrganisationName,
                PreviousName = prevOrganisationName,
                PartialNameForSuffixSearches        = OrganisationName,
                PartialNameForCompleteTokenSearches = OrganisationName,
                Abbreviations      = abbreviations.ToArray(),
                Size               = GetLatestReturn() == null ? 0 : (int)GetLatestReturn().OrganisationSize,
                SicSectionIds      = sicCodes.Select(sic => sic.SicCode.SicSectionId.ToString()).Distinct().ToArray(),
                SicSectionNames    = sicCodes.Select(sic => sic.SicCode.SicSection.Description).Distinct().ToArray(),
                SicCodeIds         = sicCodes.Select(sicCode => sicCode.SicCodeId.ToString()).Distinct().ToArray(),
                Address            = GetLatestAddress()?.GetAddressString(),
                LatestReportedDate = submittedReports.Select(x => x.Created).FirstOrDefault(),
                ReportedYears      = submittedReports.Select(x => x.AccountingDate.Year.ToString()).ToArray(),
                ReportedLateYears  =
                    submittedReports.Where(x => x.IsLateSubmission).Select(x => x.AccountingDate.Year.ToString()).ToArray(),
                ReportedExplanationYears = submittedReports.Where(x => string.IsNullOrEmpty(x.CompanyLinkToGPGInfo) == false)
                                           .Select(x => x.AccountingDate.Year.ToString())
                                           .ToArray()
            };

            if (listOfSicCodeSearchModels != null)
            {
                result.SicCodeListOfSynonyms = GetListOfSynonyms(result.SicCodeIds, listOfSicCodeSearchModels);
            }

            return(result);
        }
示例#4
0
 public override string GetContainerName()
 {
     return(OrganisationId.ToString());
 }