public async Task <GetAllProviderLocationsQueryResult> Handle(GetAllProviderLocationsQuery request, CancellationToken cancellationToken) { var response = await _courseManagementApiClient.Get <List <ProviderLocationModel> >(request); return(new GetAllProviderLocationsQueryResult() { ProviderLocations = response }); }
public async Task <HttpStatusCode> Handle(UpdateStandardSubRegionsCommand command, CancellationToken cancellationToken) { var existingProviderLocation = await _innerApiClient.Get <List <ProviderLocationModel> >(new GetAllProviderLocationsQuery(command.Ukprn)); var existingSubregions = existingProviderLocation.FindAll(l => l.LocationType == LocationType.Regional); List <int> newSubregionIdsToAdd = GetProviderLocationsToAdd(command, existingSubregions); await CreateProviderLocations(command, newSubregionIdsToAdd); await DeleteExistingProviderCourseLocationRegions(command); await CreateProviderCourseLocationRegions(command); await CleanUpUnusedProviderLocations(command); return(HttpStatusCode.NoContent); }
public async Task <Unit> Handle(UpdateApprovedByRegulatorCommand command, CancellationToken cancellationToken) { var providerCourse = await _innerApiClient.Get <GetProviderCourseResponse>(new GetProviderCourseRequest(command.Ukprn, command.LarsCode)); var updateProviderCourse = new ProviderCourseUpdateModel { Ukprn = command.Ukprn, LarsCode = command.LarsCode, UserId = command.UserId, ContactUsEmail = providerCourse.ContactUsEmail, ContactUsPhoneNumber = providerCourse.ContactUsPhoneNumber, ContactUsPageUrl = providerCourse.ContactUsPageUrl, StandardInfoUrl = providerCourse.StandardInfoUrl, IsApprovedByRegulator = command.IsApprovedByRegulator }; var request = new ProviderCourseUpdateRequest(updateProviderCourse); await _innerApiClient.Put(request); return(Unit.Value); }
public async Task <List <GetAllCoursesResult> > Handle(GetAllCoursesQuery request, CancellationToken cancellationToken) { _logger.LogInformation("Get Course request received for Ukprn number {Ukprn}", request.Ukprn); try { var courses = await _courseManagementApiClient.Get <List <GetAllCoursesResponse> >(new GetAllCoursesRequest(request.Ukprn)); if (courses == null) { _logger.LogInformation("Courses data not found for {ukprn}", request.Ukprn); return(null); } var results = new List <GetAllCoursesResult>(); foreach (var c in courses) { var course = new GetAllCoursesResult { ProviderCourseId = c.ProviderCourseId, CourseName = c.CourseName, Level = c.Level, IsImported = c.IsImported, LarsCode = c.LarsCode, ApprovalBody = c.ApprovalBody, Version = c.Version, IsApprovedByRegulator = c.IsApprovedByRegulator }; results.Add(course); } return(results); } catch (Exception ex) { _logger.LogError(ex, $"Error occurred trying to retrieve Courses for Ukprn {request.Ukprn}"); throw; } }