Example #1
0
        public static GitHubStats MappToStats(GitHubProfile profile, IEnumerable <GitHubRepos> repos)
        {
            GitHubStats result = new GitHubStats();

            if (profile != null)
            {
                result.name                = profile.login;
                result.url_git             = profile.url;
                result.number_repositories = profile.public_repos;
                result.location            = profile.location;
                result.created_at          = profile.created_at;
                result.updated_at          = profile.updated_at;
            }
            if (repos.Count() > 0)
            {
                foreach (var repo in repos)
                {
                    GitHubRepoStats repoStat = new GitHubRepoStats();
                    repoStat.name           = repo.name;
                    repoStat.url_repository = repo.html_url;
                    repoStat.created_at     = repo.created_at;
                    repoStat.updated_at     = repo.updated_at;
                    result.repos.Add(repoStat);
                }
            }
            return(result);
        }
        public async Task <IActionResult> GetStatsForReact()
        {
            GitHubStats result = new GitHubStats();

            try
            {
                result = await _gitHubService.GetStatsForReact();

                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw new Utils.HttpStatusCodeException(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }
Example #3
0
        public async Task <GitHubStats> GetStatsForReact()
        {
            GitHubStats result = new GitHubStats();
            var         uri    = _config["GitHub:GithubReposUri"];

            try
            {
                var profile = await GetProfile();

                var repos = await GetRepos();

                result = Mapping.MappToStats(profile, repos);
            }
            catch (Exception ex)
            {
                throw new HttpStatusCodeException(HttpStatusCode.InternalServerError, ex.ToString());
            }
            return(result);
        }