public async Task <IEnumerable <Project> > GetByUserIdAsync(string userId) { var user = await _securityContext.GetUserAsync(); if (user != null && await _securityContext.MatchUserIdAsync(userId)) { if (user.Projects != null && user.Projects.Count() > 0) { var result = new List <Project> { }; foreach (var projectId in user.Projects) { var entity = await _cosmosToggleDataContext.ProjectRepository.GetByIdAsync(projectId, projectId); if (entity != null) { result.Add(_mapper.Map <Project>(entity)); } } if (result.Count == 0) { await _notificationContext.AddAsync(HttpStatusCode.NotFound, $"Projects not found"); return(null); } return(result); } else { await _notificationContext.AddAsync(HttpStatusCode.NotFound, $"Projects not found"); } } return(null); }