/// <summary> /// Maps the supplied common organisation type to a reference data organisation type and throws an exception if this cannot be done. /// </summary> public static ReferenceDataOrganisationType ToReferenceDataOrganisationType(this CommonOrganisationType organisationType) { if (organisationType.TryToReferenceDataOrganisationType(out ReferenceDataOrganisationType result)) { return(result); } // It is not possible to convert values of PublicBodies and Other to a reference data organisation type (as the mapping is 1:m). throw new InvalidOrganisationTypeConversionException($"Can not convert Reference Data {organisationType} to a value of {typeof(ReferenceDataOrganisationType).FullName}"); }
public async Task <bool> IsIdentifiableOrganisationType(CommonOrganisationType organisationType) { if (organisationType.TryToReferenceDataOrganisationType(out ReferenceDataOrganisationType referenceDataType)) { var locateableOrganisationTypes = await _identifiableOrganisationTypes.Value; return(locateableOrganisationTypes.Contains(organisationType)); } return(false); }
public static string GetFriendlyName(this CommonOrganisationType commonOrganisationType) { switch (commonOrganisationType) { case CommonOrganisationType.CompaniesHouse: return("Companies House"); case CommonOrganisationType.Charities: return("Charity Commission"); case CommonOrganisationType.PublicBodies: return("Public Bodies"); default: return("Other"); } }
/// <summary> /// Maps the supplied common organisation type to a reference data organisation type and returns false if this cannot be done. /// </summary> public static bool TryToReferenceDataOrganisationType(this CommonOrganisationType organisationType, out ReferenceDataOrganisationType referenceDataType) { switch (organisationType) { case CommonOrganisationType.Charities: referenceDataType = ReferenceDataOrganisationType.Charity; return(true); case CommonOrganisationType.CompaniesHouse: referenceDataType = ReferenceDataOrganisationType.Company; return(true); default: // We have to set the out param to something and there is no 'unknown' referenceDataType = ReferenceDataOrganisationType.Charity; return(false); } }
private List <OrganisationName> FilterOrganisationsByType(IEnumerable <OrganisationName> result, CommonOrganisationType organisationType) { if (organisationType == CommonOrganisationType.Other || organisationType == CommonOrganisationType.PublicBodies) { return(result.Where(x => x.Type == CommonOrganisationType.Other || x.Type == CommonOrganisationType.PublicBodies).ToList()); } return(result.Where(x => x.Type == organisationType).ToList()); }
public Task <Organisation> GetLatestDetails(CommonOrganisationType organisationType, string identifier) { return(_client.GetLatestDetails(organisationType.ToReferenceDataOrganisationType(), identifier)); }