public async Task <IActionResult> GetBuildStatuses() { var currentUser = await _userRepository.FindByUserName(User.Identity.Name); if (currentUser == null) { _logger.LogError($"Could not find currently logged in user in the database. UserName: {User.Identity.Name}"); return(StatusCode(500, "Could not find currently logged in user in the dabase. Check server logs for more information.")); } object errorDetails; if (!_ciBuildService.CheckUserConfig(currentUser, out errorDetails)) { return(BadRequest(errorDetails)); } if (_appSettings.Projects == null || _appSettings.Projects.Length == 0) { _logger.LogWarning("Config: 'App.Projects' is empty. The tool requies some projects to be defined!"); return(NoContent()); } var getBuildStatusesTasks = _appSettings.Projects.Select(p => _ciBuildService.GetBuildStatus(currentUser, p.Name)).ToArray(); Task.WaitAll(getBuildStatusesTasks); var buildStatuses = getBuildStatusesTasks.Select(gbs => gbs.Result).ToArray(); return(Json(buildStatuses)); }
public async Task <IActionResult> GetBuildStatuses() { var currentUser = await _userRepository.FindByUserName(User.Identity.Name); if (currentUser == null) { _logger.LogError($"Could not find currently logged in user in the database. UserName: {User.Identity.Name}"); return(StatusCode(500, "Could not find currently logged in user in the dabase. Check server logs for more information.")); } currentUser.DecryptData(User.FindFirst("UserSecret").Value); object errorDetails; if (!_ciBuildService.CheckConfiguration(currentUser, out errorDetails)) { return(BadRequest(errorDetails)); } var getBuildStatusesTasks = _appSettings.Projects.Select(p => _ciBuildService.GetBuildStatus(currentUser, p.Name)).ToArray(); await Task.WhenAll(getBuildStatusesTasks); var buildStatuses = getBuildStatusesTasks.Select(gbs => gbs.Result).ToArray(); return(Json(buildStatuses)); }