private IEnumerable <Repository> GetProjectsForUser(Task <User> task) { if (task.Exception == null) { User = task.Result; } if (User == null) { return(Enumerable.Empty <Repository>()); } var repos = new List <Repository>(); var orgs = GithubRepository.GetOrganisations(User.Login).Result; var userRepos = GithubRepository.GetProjects(User.Login).Result; repos.AddRange(userRepos); foreach (var org in orgs) { var orgRepos = GithubRepository.GetProjects(org.Login).Result; repos.AddRange(orgRepos); } return(repos); }
public void Login() { SearchingForRepositories = true; try { if (User == null) { GithubRepository.GetUser() .ContinueWith <IEnumerable <Repository> >(GetProjectsForUser) .ContinueWith(AssignProjects); } else { GithubRepository.GetProjects(User.Login) .ContinueWith(AssignProjects); } } catch { Projects = new ObservableCollection <Repository>(); } }