public async Task <IActionResult> GetAll() { var requestId = Guid.NewGuid().ToString(); _logger.LogInformation($"RequestID:{requestId} - Groups_GetAll called."); try { var modelList = (await _groupsService.GetAllAsync(requestId)); Guard.Against.Null(modelList, nameof(modelList), requestId); if (modelList.Count == 0) { _logger.LogError($"RequestID:{requestId} - Groups_GetAll no items found."); return(NotFound($"RequestID:{requestId} - Groups_GetAll no items found")); } return(Ok(modelList)); } catch (Exception ex) { _logger.LogError($"RequestID:{requestId} - Groups_GetAll error: {ex.Message}"); var errorResponse = JsonErrorResponse.BadRequest($"Groups_GetAll error: {ex.Message} ", requestId); return(BadRequest(errorResponse)); } }
public async Task <ActionResult <IEnumerable <FullGroupResource> > > GetGroups( [FromQuery] GroupFilterParameters filterParameters) { var groupDtoes = await _groupService.GetAllAsync(filterParameters); var groupResources = groupDtoes .Select(dto => _mapper.Map <FullGroupResource>(dto)) .ToList(); return(Ok(groupResources)); }
public async Task <IActionResult> GetAllAsync(CancellationToken ct) { var result = await _groupsService.GetAllAsync(ct); return(Ok(result.ToModel())); }