Exemplo n.º 1
0
        /// <summary>
        /// Two calls are made to this method to emulate Incremental Loading. First call (second parameter = true) returns first 7 repositories,
        /// Second call (second parameter = false) returns the rest
        ///</summary>
        /// <param name="range"></param>
        /// <param name="firstCall"></param>
        /// <returns>Trending Repositories in a Time range</returns>
        public static async Task <ObservableCollection <Repository> > GetTrendingRepos(TimeRange range, bool firstCall)
        {
            try
            {
                ObservableCollection <Repository> repos = new ObservableCollection <Repository>();
                var trendingReposNames = await HtmlParseService.ExtractTrendingRepos(range);

                var client = await UserDataService.getAuthenticatedClient();

                if (firstCall)
                {
                    for (int i = 0; i < 7; i++)
                    {
                        repos.Add(await client.Repository.Get(trendingReposNames[i].Item1, trendingReposNames[i].Item2));
                    }
                }
                else
                {
                    for (int i = 7; i < trendingReposNames.Count; i++)
                    {
                        repos.Add(await client.Repository.Get(trendingReposNames[i].Item1, trendingReposNames[i].Item2));
                    }
                }

                return(repos);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public static async Task <ObservableCollection <Issue> > GetAllIssuesForRepoByUser(long repoId)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                var issues = await client.Issue.GetAllForRepository(repoId, new RepositoryIssueRequest
                {
                    State   = ItemStateFilter.All,
                    Creator = GlobalHelper.UserLogin
                });

                ObservableCollection <Issue> issueList = new ObservableCollection <Issue>();
                foreach (Issue c in issues)
                {
                    issueList.Add(c);
                }

                return(issueList);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        public static async Task <bool> CheckStarred(Repository repo)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                return(await client.Activity.Starring.CheckStarred(repo.Owner.Login, repo.Name));
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        public static async Task <bool> FollowUser(string login)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                return(await client.User.Followers.Follow(login));
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        public static async Task <string> GetDefaultBranch(long repoId)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                var repo = await client.Repository.Get(repoId);

                return(repo.DefaultBranch);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 6
0
        public static async Task <User> getUserInfo(string login)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                var user = await client.User.Get(login);

                return(user);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 7
0
        public static async Task <ObservableCollection <string> > GetAllBranches(Repository repo)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                var branches = await client.Repository.Branch.GetAll(repo.Owner.Login, repo.Name);

                ObservableCollection <string> branchList = new ObservableCollection <string>();
                foreach (Branch i in branches)
                {
                    branchList.Add(i.Name);
                }
                return(branchList);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 8
0
        public static async Task <ObservableCollection <Repository> > GetRepositoriesForUser(string login)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                var result = await client.Repository.GetAllForUser(login);

                ObservableCollection <Repository> repos = new ObservableCollection <Repository>();
                foreach (Repository r in result)
                {
                    repos.Add(r);
                }
                return(repos);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        public static async Task <ObservableCollection <RepositoryContent> > GetRepositoryContentByPath(long repoId, string path, string branch)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                var content = await client.Repository.Content.GetAllContentsByRef(repoId, path, branch);

                ObservableCollection <RepositoryContent> contentList = new ObservableCollection <RepositoryContent>();
                foreach (RepositoryContent c in content)
                {
                    contentList.Add(c);
                }

                return(contentList);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 10
0
        public static async Task <ObservableCollection <IssueComment> > GetAllCommentsForIssue(string owner, string name, int number)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                var comments = await client.Issue.Comment.GetAllForIssue(owner, name, number);

                ObservableCollection <IssueComment> commentList = new ObservableCollection <IssueComment>();
                foreach (IssueComment c in comments)
                {
                    commentList.Add(c);
                }

                return(commentList);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 11
0
        public static async Task <ObservableCollection <Issue> > GetAllIssuesForRepo(long repoId, RepositoryIssueRequest filter)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                var issues = await client.Issue.GetAllForRepository(repoId, filter);

                ObservableCollection <Issue> issueList = new ObservableCollection <Issue>();
                foreach (Issue c in issues)
                {
                    issueList.Add(c);
                }

                return(issueList);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 12
0
        public static async Task <ObservableCollection <Repository> > SearchRepos(string query)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                var request = new SearchRepositoriesRequest(query);
                var result  = await client.Search.SearchRepo(request);

                ObservableCollection <Repository> repos = new ObservableCollection <Repository>();
                foreach (Repository r in result.Items)
                {
                    repos.Add(r);
                }
                return(repos);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 13
0
        public static async Task <ObservableCollection <Issue> > SearchIssues(string query)
        {
            try
            {
                var client = await UserDataService.getAuthenticatedClient();

                var request = new SearchIssuesRequest(query);
                var result  = await client.Search.SearchIssues(request);

                ObservableCollection <Issue> issues = new ObservableCollection <Issue>();
                foreach (Issue r in result.Items)
                {
                    issues.Add(r);
                }
                return(issues);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 14
0
        public static async Task <bool> checkFollow(string login)
        {
            var client = await UserDataService.getAuthenticatedClient();

            return(await client.User.Followers.IsFollowingForCurrent(login));
        }
Exemplo n.º 15
0
        public static async Task UnFollowUser(string login)
        {
            var client = await UserDataService.getAuthenticatedClient();

            await client.User.Followers.Unfollow(login);
        }