示例#1
0
        public async Task <IList <string> > GetPersonnelNumbersAsync([ActivityTrigger] AzureUserReaderRequest request)
        {
            await _loggingRepository.LogMessageAsync(new LogMessage { Message = $"{nameof(PersonnelNumberReaderFunction)} function started" });

            var personnelNumbers = await _azureUserReaderService.GetPersonnelNumbersAsync(request.ContainerName, request.BlobPath);

            await _loggingRepository.LogMessageAsync(new LogMessage { Message = $"{nameof(PersonnelNumberReaderFunction)} function completed" });

            return(personnelNumbers);
        }
示例#2
0
        private async Task <(HttpStatusCode StatusCode, AzureUserReaderRequest Request)> ValidateRequestAsync(HttpRequestMessage request)
        {
            AzureUserReaderRequest userReaderRequest = null;

            try
            {
                var content = await request.Content.ReadAsStringAsync();

                if (string.IsNullOrWhiteSpace(content))
                {
                    await _loggingRepository.LogMessageAsync(new LogMessage { Message = $"Request body was not provided." });

                    return(HttpStatusCode.BadRequest, null);
                }

                userReaderRequest = JsonConvert.DeserializeObject <AzureUserReaderRequest>(content);

                if (string.IsNullOrWhiteSpace(userReaderRequest.ContainerName) || string.IsNullOrWhiteSpace(userReaderRequest.BlobPath))
                {
                    await _loggingRepository.LogMessageAsync(new LogMessage { Message = $"Request body is not valid." });

                    return(HttpStatusCode.BadRequest, null);
                }
            }
            catch (Exception ex) when(ex.GetType() == typeof(JsonReaderException) || ex.GetType() == typeof(JsonSerializationException))
            {
                await _loggingRepository.LogMessageAsync(new LogMessage { Message = $"Request body is not valid." });

                return(HttpStatusCode.BadRequest, null);
            }
            catch (Exception ex)
            {
                await _loggingRepository.LogMessageAsync(new LogMessage { Message = $"Unexpected error occured when processing the request.\n{ex}" });

                return(HttpStatusCode.InternalServerError, null);
            }

            return(HttpStatusCode.OK, userReaderRequest);
        }