public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage req,
            ILogger log,
            [Inject] IApprenticeshipService apprenticeshipService)
        {
            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 apprenticeshipService.DeleteApprenticeshipsByUKPRN(UKPRN);

                if (messagesList == null)
                {
                    return(new NotFoundObjectResult(UKPRN));
                }

                return(new OkObjectResult(messagesList));
            }
            catch (Exception e)
            {
                return(new InternalServerErrorObjectResult(e));
            }
        }