Ejemplo n.º 1
0
        public async Task <CombinedUserData> GetTopReposByUser(string username, int reposCount)
        {
            var userData = await GetUserData(username);

            var allUserRepos = await GetUserRepos(username);

            var topReposByStargazerCount =
                (from repo in allUserRepos
                 orderby repo.Stargazers_Count descending
                 select repo).Take(reposCount);

            var combinedData = new CombinedUserData
            {
                UserData  = userData,
                UserRepos = topReposByStargazerCount
            };

            return(combinedData);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Index(CombinedUserData user)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToRoute("Index"));
            }

            try
            {
                var combinedUserData = await getUserDataHandler.GetTopReposByUser(user.UserData.Login, 5);

                return(View(combinedUserData));
            }
            catch (UserNotFoundException ex)
            {
                ViewBag.Error = "User Not Found";

                return(View());
            }
        }