Beispiel #1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)]
            [RequestBodyType(typeof(GetChampionPostcodesCoveredCountRequest), "Get Champion Postcodes Covered Count")] GetChampionPostcodesCoveredCountRequest req,
            ILogger log)
        {
            try
            {
                NewRelic.Api.Agent.NewRelic.SetTransactionName("UserService", "GetChampionPostcodesCoveredCount");
                log.LogInformation("C# HTTP trigger function processed a request.");

                GetChampionPostcodesCoveredCountResponse response = await _mediator.Send(req);

                return(new OkObjectResult(ResponseWrapper <GetChampionPostcodesCoveredCountResponse, UserServiceErrorCode> .CreateSuccessfulResponse(response)));
            }
            catch (Exception exc)
            {
                LogError.Log(log, exc, req);

                return(new ObjectResult(ResponseWrapper <GetChampionPostcodesCoveredCountResponse, UserServiceErrorCode> .CreateUnsuccessfulResponse(UserServiceErrorCode.UnhandledError, "Internal Error"))
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
            [RequestBodyType(typeof(PostCreateSupportForPostCodeRequest), "Post Create Support For PostCode")] PostCreateSupportForPostCodeRequest req,
            ILogger log)
        {
            try
            {
                NewRelic.Api.Agent.NewRelic.SetTransactionName("UserService", "PostCreateSupportForPostCode");
                log.LogInformation("C# HTTP trigger function processed a request.");

                await _mediator.Send(req);

                return(new NoContentResult());
            }
            catch (Exception exc)
            {
                LogError.Log(log, exc, req);

                return(new ObjectResult(exc)
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }
        }