public ReportController(ICourseService courseService, ICSVHelper csvHelper, IApprenticeshipService apprenticeshipService) { _courseService = courseService; _CSVHelper = csvHelper; _apprenticeshipService = apprenticeshipService; }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { string fromQuery = req.Query["UKPRN"]; List <Apprenticeship> persisted = null; if (string.IsNullOrWhiteSpace(fromQuery)) { return(new BadRequestObjectResult($"Empty or missing UKPRN value.")); } if (!int.TryParse(fromQuery, out int UKPRN)) { return(new BadRequestObjectResult($"Invalid UKPRN value, expected a valid integer")); } try { persisted = (List <Apprenticeship>) await apprenticeshipService.GetApprenticeshipByUKPRN(UKPRN); if (persisted == null) { return(new NotFoundObjectResult(UKPRN)); } var tribalProviders = (List <TribalProvider>)apprenticeshipService.ApprenticeshipsToTribalProviders(persisted); return(new OkObjectResult(tribalProviders)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { string fromQuery = req.Query["UKPRN"]; if (string.IsNullOrWhiteSpace(fromQuery)) { return(new BadRequestObjectResult($"Empty or missing UKPRN value.")); } if (!int.TryParse(fromQuery, out int UKPRN)) { return(new BadRequestObjectResult($"Invalid UKPRN value, expected a valid integer")); } try { var results = await apprenticeshipService.GetApprenticeshipDashboardCounts(UKPRN); if (results == null) { return(new NotFoundObjectResult(UKPRN)); } return(new OkObjectResult(results)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public ProviderApprenticeshipsController( ILogger <ProviderApprenticeshipsController> logger, ICourseService courseService, IVenueService venueService, IApprenticeshipService apprenticeshipService) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (courseService == null) { throw new ArgumentNullException(nameof(courseService)); } if (venueService == null) { throw new ArgumentNullException(nameof(venueService)); } if (apprenticeshipService == null) { throw new ArgumentNullException(nameof(apprenticeshipService)); } _logger = logger; _courseService = courseService; _venueService = venueService; _apprenticeshipService = apprenticeshipService; }
public BlobStorageController( ICourseService courseService, IApprenticeshipService apprenticeshipService, IBlobStorageService blobService, ICourseProvisionHelper courseProvisionHelper, IApprenticeshipProvisionHelper apprenticeshipProvisionHelper) { if (courseService == null) { throw new ArgumentNullException(nameof(courseService)); } if (apprenticeshipService == null) { throw new ArgumentNullException(nameof(apprenticeshipService)); } if (blobService == null) { throw new ArgumentNullException(nameof(blobService)); } if (apprenticeshipProvisionHelper == null) { throw new ArgumentNullException(nameof(apprenticeshipProvisionHelper)); } _courseService = courseService; _blobService = blobService; _courseProvisionHelper = courseProvisionHelper; _apprenticeshipService = apprenticeshipService; _apprenticeshipProvisionHelper = apprenticeshipProvisionHelper; }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { List <Apprenticeship> persisted = null; try { persisted = (List <Apprenticeship>) await apprenticeshipService.GetUpdatedApprenticeships(); if (persisted == null) { return(new EmptyResult()); } var listOfProviderUKPRN = persisted.Select(x => x.ProviderUKPRN.ToString()) .Distinct() .ToList(); List <Apprenticeship> totalList = new List <Apprenticeship>(); foreach (var ukprn in listOfProviderUKPRN) { var results = apprenticeshipService.GetApprenticeshipByUKPRN(int.Parse(ukprn)).Result; if (results.Any()) { totalList.AddRange((List <Apprenticeship>)results); } } var providers = apprenticeshipService.ApprenticeshipsToTribalProviders(totalList); return(new OkObjectResult(providers)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public EditDeliveryMethodController( ILogger <EditDeliveryMethodController> logger, IApprenticeshipService apprenticeshipService, IOptions <ApprenticeshipSettings> apprenticeshipSettings) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (apprenticeshipService == null) { throw new ArgumentNullException(nameof(apprenticeshipService)); } if (apprenticeshipSettings == null) { throw new ArgumentNullException(nameof(apprenticeshipSettings)); } _apprenticeshipSettings = apprenticeshipSettings; _logger = logger; _apprenticeshipService = apprenticeshipService; }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { string fromQuery = req.Query["id"]; Apprenticeship persisted = null; if (string.IsNullOrWhiteSpace(fromQuery)) { return(new BadRequestObjectResult($"Empty or missing id value.")); } if (!Guid.TryParse(fromQuery, out Guid id)) { return(new BadRequestObjectResult($"Invalid id value. Expected a non-empty valid {nameof(Guid)}")); } try { persisted = (Apprenticeship)await apprenticeshipService.GetApprenticeshipById(id); if (persisted == null) { return(new NotFoundObjectResult(id)); } return(new OkObjectResult(persisted)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { using (var streamReader = new StreamReader(req.Body)) { var requestBody = await streamReader.ReadToEndAsync(); Apprenticeship fromBody = null; Apprenticeship persisted = null; try { fromBody = JsonConvert.DeserializeObject <Apprenticeship>(requestBody); } catch (Exception e) { return(new BadRequestObjectResult(e)); } try { persisted = (Apprenticeship)await apprenticeshipService.AddApprenticeship(fromBody); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } return(new CreatedResult(persisted.id.ToString(), persisted)); } }
public GetEligibleApprenticeshipsSearchHandler( ICommitmentsService commitmentsV2Service, IEmployerIncentivesService employerIncentivesService, IApprenticeshipService apprenticeshipService) { _commitmentsV2Service = commitmentsV2Service; _employerIncentivesService = employerIncentivesService; _apprenticeshipService = apprenticeshipService; }
public EditApprenticeshipController(IApprenticeshipService apprenticeshipService) { if (apprenticeshipService == null) { throw new ArgumentNullException(nameof(apprenticeshipService)); } _apprenticeshipService = apprenticeshipService; }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { string codeFromQuery = req.Query["FrameworkCode"]; string progTypeFromQuery = req.Query["ProgType"]; string pathwayCodeFromQuery = req.Query["PathwayCode"]; List <StandardsAndFrameworks> persisted = null; if (string.IsNullOrWhiteSpace(codeFromQuery)) { return(new BadRequestObjectResult($"Empty or missing Framework Code value.")); } if (!int.TryParse(codeFromQuery, out int frameworkCode)) { return(new BadRequestObjectResult($"Invalid Framework Code value, expected a valid integer")); } if (string.IsNullOrWhiteSpace(progTypeFromQuery)) { return(new BadRequestObjectResult($"Empty or missing ProgType value.")); } if (!int.TryParse(progTypeFromQuery, out int progType)) { return(new BadRequestObjectResult($"Invalid ProgType value, expected a valid integer")); } if (string.IsNullOrWhiteSpace(pathwayCodeFromQuery)) { return(new BadRequestObjectResult($"Empty or missing Pathway code value.")); } if (!int.TryParse(pathwayCodeFromQuery, out int pathwayCode)) { return(new BadRequestObjectResult($"Invalid Pathway code value, expected a valid integer")); } try { persisted = await apprenticeshipService.GetFrameworkByCode(frameworkCode, progType, pathwayCode); if (persisted == null) { return(new NotFoundObjectResult(frameworkCode)); } return(new OkObjectResult(persisted)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public BulkUploadApprenticeshipsController( IApprenticeshipBulkUploadService apprenticeshipBulkUploadService, IApprenticeshipService apprenticeshipService, IBlobStorageService blobService, ICourseService courseService, IProviderService providerService, IUserHelper userHelper) { if (apprenticeshipBulkUploadService == null) { throw new ArgumentNullException(nameof(apprenticeshipBulkUploadService)); } if (blobService == null) { throw new ArgumentNullException(nameof(blobService)); } if (courseService == null) { throw new ArgumentNullException(nameof(courseService)); } if (courseService == null) { throw new ArgumentNullException(nameof(courseService)); } if (providerService == null) { throw new ArgumentNullException(nameof(providerService)); } if (userHelper == null) { throw new ArgumentNullException(nameof(userHelper)); } if (apprenticeshipService == null) { throw new ArgumentNullException(nameof(apprenticeshipService)); } _apprenticeshipBulkUploadService = apprenticeshipBulkUploadService; _blobService = blobService; _courseService = courseService; _courseService = courseService; _providerService = providerService; _userHelper = userHelper; _apprenticeshipService = apprenticeshipService; }
public VenuesController( IAddressSearchService addressSearchService, IVenueSearchHelper venueSearchHelper, IVenueService venueService, ICourseService courseService, IApprenticeshipService apprenticeshipService, ISearchClient <Core.Search.Models.Onspd> searchClient) { _addressSearchService = addressSearchService ?? throw new ArgumentNullException(nameof(addressSearchService)); _venueSearchHelper = venueSearchHelper ?? throw new ArgumentNullException(nameof(venueSearchHelper)); _venueService = venueService ?? throw new ArgumentNullException(nameof(venueService)); _courseService = courseService ?? throw new ArgumentNullException(nameof(courseService)); _apprenticeshipService = apprenticeshipService ?? throw new ArgumentNullException(nameof(apprenticeshipService)); _searchClient = searchClient ?? throw new ArgumentNullException(nameof(searchClient)); }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { try { var allCourses = await apprenticeshipService.GetTotalLiveApprenticeships(); return(new OkObjectResult(allCourses)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { Apprenticeship apprenticeship = await req.Content.ReadAsAsync <Apprenticeship>(); try { var updatedCourse = (Apprenticeship)await apprenticeshipService.Update(apprenticeship); return(new OkObjectResult(updatedCourse)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public GetApprenticeshipsAsProviderIntegrationTests() { _nowUtc = new Mock <Func <DateTimeOffset> >(); _blobStorageClient = new Mock <IBlobStorageClient>(); _providerService = new Mock <IProviderService>(); _providerServiceClient = new ProviderServiceClient(_providerService.Object); _cosmosDbQueryDispatcher = new Mock <ICosmosDbQueryDispatcher>(); _sqlQueryDispatcher = new Mock <ISqlQueryDispatcher>(); var telemetryClient = MockTelemetryHelper.Initialize(); _DASHelper = new DASHelper(telemetryClient); _apprenticeshipService = new ApprenticeshipService(_DASHelper, _providerServiceClient, telemetryClient, _sqlQueryDispatcher.Object, _cosmosDbQueryDispatcher.Object); _generateProviderExportFunction = new GenerateProviderExportFunction(_apprenticeshipService, _blobStorageClient.Object); _getApprenticeshipAsProviderFunction = new GetApprenticeshipsAsProvider(_blobStorageClient.Object, _nowUtc.Object); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { using (var streamReader = new StreamReader(req.Body)) { var requestBody = await streamReader.ReadToEndAsync(); // Default to processing in parallel if query parameter is not supplied var processInParallel = !req.Query["parallel"].ToString().Equals("false", StringComparison.OrdinalIgnoreCase); var apprenticeships = JsonConvert.DeserializeObject <IEnumerable <Apprenticeship> >(requestBody); if (processInParallel) { using (var throttle = new SemaphoreSlim(MaxConcurrency)) { await Task.WhenAll(apprenticeships.Select(async a => { await throttle.WaitAsync(); try { await apprenticeshipService.AddApprenticeship(a); } finally { throttle.Release(); } })); } } else { foreach (var app in apprenticeships) { await apprenticeshipService.AddApprenticeship(app); } } return(new OkResult()); } }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequestMessage req, ILogger log, [Inject] IApprenticeshipService coursesService) { log.LogInformation($"DeleteCoursesByUKPRN starting"); string strUKPRN = req.RequestUri.ParseQueryString()["UKPRN"]?.ToString() ?? (await(dynamic) req.Content.ReadAsAsync <object>())?.UKPRN; List <string> messagesList = null; if (string.IsNullOrWhiteSpace(strUKPRN)) { return(new BadRequestObjectResult($"Empty or missing UKPRN value.")); } if (!int.TryParse(strUKPRN, out int UKPRN)) { return(new BadRequestObjectResult($"Invalid UKPRN value, expected a valid integer")); } try { messagesList = await coursesService.DeleteBulkUploadApprenticeships(UKPRN); await coursesService.ChangeApprenticeshipStatusForUKPRNSelection(UKPRN, RecordStatus.MigrationPending, RecordStatus.Archived); await coursesService.ChangeApprenticeshipStatusForUKPRNSelection(UKPRN, RecordStatus.MigrationReadyToGoLive, RecordStatus.Archived); if (messagesList == null) { return(new NotFoundObjectResult(UKPRN)); } return(new OkObjectResult(messagesList)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public Dashboard(ICourseService courseService, IVenueService venueService, IBlobStorageService blobStorageService, IApprenticeshipService apprenticeshipService, IProviderService providerService, IEnvironmentHelper environmentHelper, ISqlQueryDispatcher sqlQueryDispatcher, IProviderContextProvider providerContextProvider) { if (courseService == null) { throw new ArgumentNullException(nameof(courseService)); } if (apprenticeshipService == null) { throw new ArgumentNullException(nameof(apprenticeshipService)); } if (venueService == null) { throw new ArgumentNullException(nameof(venueService)); } if (blobStorageService == null) { throw new ArgumentNullException(nameof(blobStorageService)); } if (providerService == null) { throw new ArgumentNullException(nameof(providerService)); } if (environmentHelper == null) { throw new ArgumentNullException(nameof(environmentHelper)); } _apprenticeshipService = apprenticeshipService; _courseService = courseService; _venueService = venueService; _blobStorageService = blobStorageService; _providerService = providerService; _environmentHelper = environmentHelper; _sqlQueryDispatcher = sqlQueryDispatcher; _providerContextProvider = providerContextProvider; }
public ApprenticeshipProcessor(IPaymentLogger logger, IMapper mapper, IApprenticeshipService apprenticeshipService, IEndpointInstanceFactory endpointInstanceFactory, IApprenticeshipApprovedUpdatedService apprenticeshipApprovedUpdatedService, IApprenticeshipDataLockTriageService apprenticeshipDataLockTriageService, IApprenticeshipStoppedService apprenticeshipStoppedService, IApprenticeshipPauseService apprenticeshipPauseService, IApprenticeshipResumedService apprenticeshipResumedService) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); this.apprenticeshipService = apprenticeshipService ?? throw new ArgumentNullException(nameof(apprenticeshipService)); this.endpointInstanceFactory = endpointInstanceFactory ?? throw new ArgumentNullException(nameof(endpointInstanceFactory)); this.apprenticeshipApprovedUpdatedService = apprenticeshipApprovedUpdatedService ?? throw new ArgumentNullException(nameof(apprenticeshipApprovedUpdatedService)); this.apprenticeshipDataLockTriageService = apprenticeshipDataLockTriageService ?? throw new ArgumentNullException(nameof(apprenticeshipDataLockTriageService)); this.apprenticeshipStoppedService = apprenticeshipStoppedService ?? throw new ArgumentNullException(nameof(apprenticeshipStoppedService)); this.apprenticeshipPauseService = apprenticeshipPauseService ?? throw new ArgumentNullException(nameof(apprenticeshipPauseService)); this.apprenticeshipResumedService = apprenticeshipResumedService ?? throw new ArgumentNullException(nameof(apprenticeshipResumedService)); }
public ApprenticeshipsController( ILogger <ApprenticeshipsController> logger, ICourseService courseService, IVenueService venueService , IApprenticeshipService apprenticeshipService, IProviderService providerService, IOptions <ApprenticeshipSettings> apprenticeshipSettings) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (courseService == null) { throw new ArgumentNullException(nameof(courseService)); } if (venueService == null) { throw new ArgumentNullException(nameof(venueService)); } if (apprenticeshipService == null) { throw new ArgumentNullException(nameof(apprenticeshipService)); } if (providerService == null) { throw new ArgumentNullException(nameof(providerService)); } if (apprenticeshipSettings == null) { throw new ArgumentNullException(nameof(apprenticeshipSettings)); } _apprenticeshipSettings = apprenticeshipSettings; _logger = logger; _courseService = courseService; _venueService = venueService; _apprenticeshipService = apprenticeshipService; _providerService = providerService; }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { string search = req.Query["search"]; string fromUKPRN = req.Query["UKPRN"]; IEnumerable <IStandardsAndFrameworks> standardsAndFrameworks = null; if (string.IsNullOrWhiteSpace(fromUKPRN)) { return(new BadRequestObjectResult($"Empty or missing UKPRN value.")); } if (!int.TryParse(fromUKPRN, out int UKPRN)) { return(new BadRequestObjectResult($"Invalid UKPRN value, expected a valid integer")); } if (string.IsNullOrWhiteSpace(search)) { return(new BadRequestObjectResult($"Empty or missing search value.")); } try { standardsAndFrameworks = await apprenticeshipService.StandardsAndFrameworksSearch(search); standardsAndFrameworks = apprenticeshipService.CheckForDuplicateApprenticeships(standardsAndFrameworks, UKPRN); if (standardsAndFrameworks == null) { return(new NotFoundObjectResult(search)); } return(new OkObjectResult(standardsAndFrameworks)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public ApprenticeshipProvisionHelper( ILogger <ApprenticeshipProvisionHelper> logger, IHttpContextAccessor contextAccessor, IApprenticeshipService apprenticeshipService, IVenueService venueService, IProviderService providerService, ICSVHelper CSVHelper) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (contextAccessor == null) { throw new ArgumentNullException(nameof(contextAccessor)); } if (apprenticeshipService == null) { throw new ArgumentNullException(nameof(apprenticeshipService)); } if (venueService == null) { throw new ArgumentNullException(nameof(venueService)); } if (providerService == null) { throw new ArgumentNullException(nameof(providerService)); } _logger = logger; _contextAccessor = contextAccessor; _apprenticeshipService = apprenticeshipService; _venueService = venueService; _providerService = providerService; _CSVHelper = CSVHelper; }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { List <Apprenticeship> persisted = null; try { persisted = (List <Apprenticeship>) await apprenticeshipService.GetUpdatedApprenticeships(); if (persisted == null) { return(new EmptyResult()); } return(new OkObjectResult(persisted)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public GetApprenticeshipsAsProviderIntegrationTests() { _telemetryClient = new TelemetryClient(); _nowUtc = new Mock <Func <DateTimeOffset> >(); _blobStorageClient = new Mock <IBlobStorageClient>(); _cosmosDbHelper = new Mock <ICosmosDbHelper>(); _cosmosSettings = Options.Create(new CosmosDbCollectionSettings()); _referenceDataResponse = new Mock <Func <HttpRequestMessage, CancellationToken, Task <HttpResponseMessage> > >(); _referenceDataService = new ReferenceDataService(new HttpClient(new MockHttpMessageHandler(_referenceDataResponse.Object)) { BaseAddress = new Uri("https://test.com") }); _referenceDataServiceClient = new ReferenceDataServiceClient(_referenceDataService); _providerService = new Mock <IProviderService>(); _providerServiceClient = new ProviderServiceClient(_providerService.Object); _DASHelper = new DASHelper(_telemetryClient); _apprenticeshipService = new ApprenticeshipService(_cosmosDbHelper.Object, _cosmosSettings, _DASHelper, _providerServiceClient, _referenceDataServiceClient, _telemetryClient); _generateProviderExportFunction = new GenerateProviderExportFunction(_apprenticeshipService, _blobStorageClient.Object); _getApprenticeshipAsProviderFunction = new GetApprenticeshipsAsProvider(_blobStorageClient.Object, _nowUtc.Object); }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { string fromQuery = req.Query["UKPRN"]; List <Apprenticeship> apprenticeships = null; try { apprenticeships = (List <Apprenticeship>) await apprenticeshipService.GetApprenticeshipCollection(); if (apprenticeships == null) { return(new NotFoundObjectResult("Could not retrieve apprenticeships")); } var tribalProviders = (List <TribalProvider>)apprenticeshipService.ApprenticeshipsToTribalProviders(apprenticeships); return(new OkObjectResult(tribalProviders)); } catch (Exception e) { return(new InternalServerErrorObjectResult(e)); } }
public GetApprenticeshipsAsProviderByUkprn(IApprenticeshipService apprenticeshipService) { _apprenticeshipService = apprenticeshipService ?? throw new ArgumentNullException(nameof(apprenticeshipService)); }
public GenerateProviderExportFunction(IApprenticeshipService apprenticeshipService, IBlobStorageClient blobStorageClient) { _apprenticeshipService = apprenticeshipService ?? throw new ArgumentNullException(nameof(apprenticeshipService)); _blobStorageClient = blobStorageClient ?? throw new ArgumentNullException(nameof(blobStorageClient)); }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequestMessage req, ILogger log, [Inject] IApprenticeshipService apprenticeshipService) { var qryUKPRN = req.RequestUri.ParseQueryString()["UKPRN"]?.ToString() ?? (await(dynamic) req.Content.ReadAsAsync <object>())?.UKPRN; var qryCurrentStatus = req.RequestUri.ParseQueryString()["CurrentStatus"]?.ToString() ?? (await(dynamic) req.Content.ReadAsAsync <object>())?.CurrentStatus; var qryStatusToBeChangedTo = req.RequestUri.ParseQueryString()["StatusToBeChangedTo"]?.ToString() ?? (await(dynamic) req.Content.ReadAsAsync <object>())?.StatusToBeChangedTo;; if (string.IsNullOrWhiteSpace(qryUKPRN)) { return(new BadRequestObjectResult($"Empty or missing UKPRN value.")); } if (!int.TryParse(qryUKPRN, out int UKPRN)) { return(new BadRequestObjectResult($"Invalid UKPRN value, expected a valid integer")); } if (string.IsNullOrWhiteSpace(qryCurrentStatus)) { return(new BadRequestObjectResult($"Empty or missing CurrentStatus value.")); } if (!int.TryParse(qryCurrentStatus, out int intCurrentStatus)) { return(new BadRequestObjectResult($"Invalid CurrentStatus value, expected a valid integer")); } RecordStatus CurrentStatus = (RecordStatus)intCurrentStatus; if (string.IsNullOrWhiteSpace(qryStatusToBeChangedTo)) { return(new BadRequestObjectResult($"Empty or missing StatusToBeChangedTo value.")); } if (!int.TryParse(qryStatusToBeChangedTo, out int intStatusToBeChangedTo)) { return(new BadRequestObjectResult($"Invalid StatusToBeChangedTo value, expected a valid integer")); } RecordStatus StatusToBeChangedTo = RecordStatus.Undefined; if (Enum.IsDefined(typeof(RecordStatus), intStatusToBeChangedTo)) { StatusToBeChangedTo = (RecordStatus)Enum.ToObject(typeof(RecordStatus), intStatusToBeChangedTo); } else { return(new BadRequestObjectResult($"StatusToBeChangedTo value cannot be parse into valid RecordStatus")); } if (StatusToBeChangedTo.Equals(RecordStatus.Undefined)) { return(new BadRequestObjectResult($"StatusToBeChangedTo value is not allowed to be with Undefined RecordStatus")); } await apprenticeshipService.ChangeApprenticeshipStatusForUKPRNSelection(UKPRN, CurrentStatus, StatusToBeChangedTo); return(new OkResult()); }