private static CourseSearchRequest BuildCourseSearchRequest(CourseSearchProperties input) { return(new CourseSearchRequest { Distance = input.Filters.DistanceSpecified ? input.Filters.Distance : default(float), Start = input.Count * (input.Page - 1), Limit = input.Count, DeliveryModes = input.Filters.CourseType.MapToDeliveryModes(), StudyModes = input.Filters.CourseHours.MapToStudyModes(), Town = input.Filters?.Town, Postcode = input.Filters?.PostCode, SortBy = input.OrderedBy.MapToSortBy(), StartDateFrom = input.Filters.StartDate.GetEarliestStartDate(input.Filters.StartDateFrom), SubjectKeyword = input.Filters.SearchTerm, ProviderName = input.Filters?.Provider, }); }
public async Task <CourseSearchResult> SearchCoursesAsync(CourseSearchProperties courseSearchProperties) { if (string.IsNullOrWhiteSpace(courseSearchProperties.Filters.SearchTerm)) { return(await Task.FromResult <CourseSearchResult>(null)); } var request = BuildCourseSearchRequest(courseSearchProperties); var apiResult = await findACourseClient.CourseSearchAsync(request).ConfigureAwait(false); return(new CourseSearchResult { ResultProperties = { TotalPages = apiResult?.Total == 0 ? 0 : GetTotalPages((apiResult?.Total).GetValueOrDefault(), (apiResult?.Limit).GetValueOrDefault()), TotalResultCount = (apiResult?.Total).GetValueOrDefault(), Page = apiResult?.Start == 0 ? 0 : GetCurrentPageNumber((apiResult?.Start).GetValueOrDefault(), (apiResult?.Limit).GetValueOrDefault()), OrderedBy = courseSearchProperties.OrderedBy, }, Courses = mapper.Map <List <Course> >(apiResult?.Results), }); }
private static CourseSearchRequest BuildCourseSearchRequest(CourseSearchProperties input) { return(new CourseSearchRequest { Distance = input.Filters.DistanceSpecified ? input.Filters.Distance : default,