public async Task <IList <DashboardModel> > GetAllAsync(string requestId = "") { _logger.LogInformation($"RequestId: {requestId} - DashboardSvc_GetAllAsync called."); try { var listItems = (await _dashboardRepository.GetAllAsync(requestId)).ToList(); Guard.Against.Null(listItems, nameof(listItems), requestId); var modelListItems = new List <DashboardModel>(); foreach (var item in listItems) { modelListItems.Add(MapToModel(item)); } if (modelListItems.Count == 0) { _logger.LogWarning($"RequestId: {requestId} - DashboardSvc_GetAllAsync no items found"); throw new NoItemsFound($"RequestId: {requestId} - Method name: DashboardSvc_GetAllAsync - No Items Found"); } return(modelListItems); } catch (Exception ex) { _logger.LogError($"RequestId: {requestId} - CategorySvc_GetAllAsync error: " + ex); throw; } }
public async Task <ActionResult <IEnumerable <Dashboard> > > GetDashboards() { var dashboards = await _dashboardRepository.GetAllAsync(); if (dashboards == null) { return(NotFound()); } return(Ok(dashboards)); }