예제 #1
0
        public static List <string> GetAddressLines(this OrganisationAddress address)
        {
            var list = new List <string>();

            if (address == null)
            {
                return(list);
            }

            if (!string.IsNullOrWhiteSpace(address.Address1))
            {
                list.Add(address.Address1.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(address.Address2))
            {
                list.Add(address.Address2.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(address.Address3))
            {
                list.Add(address.Address3.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(address.TownCity))
            {
                list.Add(address.TownCity.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(address.County))
            {
                list.Add(address.County.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(address.Country))
            {
                list.Add(address.Country.TrimI());
            }

            if (!string.IsNullOrWhiteSpace(address.GetPostCodeInAllCaps()))
            {
                list.Add(address.GetPostCodeInAllCaps().TrimI());
            }

            if (!string.IsNullOrWhiteSpace(address.PoBox))
            {
                list.Add(address.PoBox.TrimI());
            }

            return(list);
        }
예제 #2
0
 public bool AddressMatches(OrganisationAddress other)
 {
     return(string.Equals(Address1, other.Address1, StringComparison.Ordinal) &&
            string.Equals(Address2, other.Address2, StringComparison.Ordinal) &&
            string.Equals(Address3, other.Address3, StringComparison.Ordinal) &&
            string.Equals(TownCity, other.TownCity, StringComparison.Ordinal) &&
            string.Equals(County, other.County, StringComparison.Ordinal) &&
            string.Equals(Country, other.Country, StringComparison.Ordinal) &&
            string.Equals(GetPostCodeInAllCaps(), other.GetPostCodeInAllCaps(), StringComparison.Ordinal) &&
            string.Equals(PoBox, other.PoBox, StringComparison.Ordinal));
 }
예제 #3
0
        public EmployerRecord ToEmployerRecord(long userId = 0)
        {
            OrganisationAddress address = null;

            if (userId > 0)
            {
                address = UserOrganisations.FirstOrDefault(uo => uo.UserId == userId)?.Address;
            }

            if (address == null)
            {
                address = GetLatestAddress();
            }

            if (address == null)
            {
                return(new EmployerRecord {
                    OrganisationId = OrganisationId,
                    SectorType = SectorType,
                    OrganisationName = OrganisationName,
                    NameSource = GetName()?.Source,
                    EmployerReference = EmployerReference,
                    DateOfCessation = DateOfCessation,
                    CompanyNumber = CompanyNumber,
                    SicSectors = GetSicSectorsString(null, ",<br/>"),
                    SicCodeIds = GetSicCodeIdsString(),
                    SicSource = GetSicSource(),
                    RegistrationStatus = GetRegistrationStatus(),
                    References = OrganisationReferences.ToDictionary(
                        r => r.ReferenceName,
                        r => r.ReferenceValue,
                        StringComparer.OrdinalIgnoreCase)
                });
            }

            return(new EmployerRecord {
                OrganisationId = OrganisationId,
                SectorType = SectorType,
                OrganisationName = OrganisationName,
                NameSource = GetName()?.Source,
                EmployerReference = EmployerReference,
                DateOfCessation = DateOfCessation,
                CompanyNumber = CompanyNumber,
                SicSectors = GetSicSectorsString(null, ",<br/>"),
                SicCodeIds = GetSicCodeIdsString(),
                SicSource = GetSicSource(),
                ActiveAddressId = address.AddressId,
                AddressSource = address.Source,
                Address1 = address.Address1,
                Address2 = address.Address2,
                Address3 = address.Address3,
                City = address.TownCity,
                County = address.County,
                Country = address.Country,
                PostCode = address.GetPostCodeInAllCaps(),
                PoBox = address.PoBox,
                IsUkAddress = address.IsUkAddress,
                RegistrationStatus = GetRegistrationStatus(),
                References = OrganisationReferences.ToDictionary(
                    r => r.ReferenceName,
                    r => r.ReferenceValue,
                    StringComparer.OrdinalIgnoreCase)
            });
        }