public async Task <ProcessTypeListViewModel> GetAllAsync(string requestId = "") { _logger.LogInformation($"RequestId: {requestId} - GetAllAsync called."); try { var listItems = (await _processRepository.GetAllAsync(requestId)).ToList(); Guard.Against.Null(listItems, nameof(listItems), requestId); var processTypeListViewModel = new ProcessTypeListViewModel(); foreach (var item in listItems) { processTypeListViewModel.ItemsList.Add(MapToProcessViewModel(item)); } if (processTypeListViewModel.ItemsList.Count == 0) { _logger.LogWarning($"RequestId: {requestId} - GetAllAsync no items found"); throw new NoItemsFound($"RequestId: {requestId} - Method name: GetAllAsync - No Items Found"); } return(processTypeListViewModel); } catch (Exception ex) { _logger.LogError($"RequestId: {requestId} - GetAllAsync Service Exception: {ex}"); throw new ResponseException($"RequestId: {requestId} - GetAllAsync Service Exception: {ex}"); } }
public async Task <ProcessTypeListViewModel> GetAllAsync(string requestId = "") { _logger.LogInformation($"RequestId: {requestId} - GetAllAsync called."); try { var processTypeListViewModel = new ProcessTypeListViewModel(); processTypeListViewModel.ItemsList = (await _processRepository.GetAllAsync(requestId)).Select(item => MapToProcessViewModel(item)).ToList(); if (processTypeListViewModel.ItemsList.Count == 0) { _logger.LogWarning($"RequestId: {requestId} - GetAllAsync no items found"); throw new NoItemsFound($"RequestId: {requestId} - Method name: GetAllAsync - No Items Found"); } return(processTypeListViewModel); } catch (Exception ex) { _logger.LogError($"RequestId: {requestId} - GetAllAsync Service Exception: {ex}"); throw new ResponseException($"RequestId: {requestId} - GetAllAsync Service Exception: {ex}"); } }