/// <summary> /// Maps the provider data from the search into a class that we can /// more easily use as a datasource. /// </summary> /// <param name="course">A single set of provider data from the search.</param> /// <returns>A ProviderSearchResult of data from the input.</returns> private ProviderSearchResult CreateResult(ProviderStructure course) { ProviderSearchResult result = new ProviderSearchResult(); if (course.Provider != null) { result.ProviderID = HttpUtility.HtmlEncode(course.Provider.ProviderID); result.ProviderName = HttpUtility.HtmlEncode(course.Provider.ProviderName); result.Email = HttpUtility.HtmlEncode(course.Provider.Email); result.Fax = HttpUtility.HtmlEncode(course.Provider.Fax); result.Phone = HttpUtility.HtmlEncode(course.Provider.Phone); result.Website = HttpUtility.HtmlEncode(course.Provider.Website); result.TFPlusLoans = course.Provider.TFPlusLoans; result.DFE1619Funded = course.Provider.DFE1619Funded; if (course.Provider.ProviderAddress != null) { result.AddressLine1 = HttpUtility.HtmlEncode(course.Provider.ProviderAddress.Address_line_1); result.AddressLine2 = HttpUtility.HtmlEncode(course.Provider.ProviderAddress.Address_line_2); result.Town = HttpUtility.HtmlEncode(course.Provider.ProviderAddress.Town); result.County = HttpUtility.HtmlEncode(course.Provider.ProviderAddress.County); result.Postcode = HttpUtility.HtmlEncode(course.Provider.ProviderAddress.PostCode); } } return(result); }
/// <summary> /// Executes a search for Providers matching the search keyword. /// </summary> /// <param name="request">ProviderSearchInput request object.</param> /// <returns>A ProviderSearchOuput object.</returns> public ProviderSearchOutput GetProviders(ProviderSearchInput request) { ProviderSearchOutput providerSearchOutput = new ProviderSearchOutput(new ProviderSearchResponseStructure()); providerSearchOutput.ProviderSearchResponse.RequestDetails = new ProviderSearchResponseStructureRequestDetails(); providerSearchOutput.ProviderSearchResponse.RequestDetails.ProviderSearch = request.ProviderSearchRequest; List <Provider> providers = _providerQuery.GetProviders(request.ProviderSearchRequest.ProviderKeyword, request.ProviderSearchRequest.APIKey); List <ProviderStructure> providerStructures = new List <ProviderStructure>(); foreach (Provider provider in providers) { ProviderStructure providerStructure = new ProviderStructure(); providerStructure.Provider = BuildProviderDetail(provider); providerStructures.Add(providerStructure); } providerSearchOutput.ProviderSearchResponse.ProviderDetails = providerStructures.ToArray(); return(providerSearchOutput); }