Beispiel #1
0
        public RepositoriesViewModel GetRepoViewModel(string username)
        {
            using (var client = new HttpClient())
            {
                try
                {
                    RepositoriesViewModel repoViewModel = new RepositoriesViewModel();
                    client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "http://developer.github.com/v3/#user-agent-required");
                    var task = client.GetAsync($"https://api.github.com/users/{username}/repos")
                               .ContinueWith((taskwithresponse) =>
                    {
                        var response = taskwithresponse.Result.Content.ReadAsStringAsync();
                        response.Wait();
                        IEnumerable <Repository> gitData = JsonConvert.DeserializeObject <IEnumerable <Repository> >(response.Result);
                        repoViewModel.repositories       = gitData;
                        repoViewModel.UserName           = username;
                    });

                    task.Wait();
                    return(repoViewModel);
                }
                catch (Exception ex)
                {
                    _logger.LogError("Error: " + ex);
                    return(null);
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            this.repositoriesViewModel = new RepositoriesViewModel();

            this.DataContext = this.repositoriesViewModel;
        }
Beispiel #3
0
        public OrgViewModel(INavigationService navigationService, IResourceLoader loader,
                            MembersViewModel vmMembers, RepositoriesViewModel vmRepos)
        {
            _navigationService = navigationService;
            _loader            = loader;

            _vmMembers = vmMembers;
            _vmRepos   = vmRepos;
        }
Beispiel #4
0
        public RepositoriesView()
        {
            InitializeComponent();

            ViewModel = new RepositoriesViewModel();

            repositories.CommandBindings.Clear();
            repositories.CommandBindings.Add(new CommandBinding(TabablzControl.AddItemCommand, Executed));
        }
        public static RepositoriesViewController CreateForkedViewController(string username, string repository)
        {
            var viewModel = RepositoriesViewModel.CreateForkedViewModel(username, repository);

            return(new RepositoriesViewController(viewModel)
            {
                Title = "Forks"
            });
        }
        public RepositoriesViewController(RepositoriesViewModel viewModel)
            : base(UITableViewStyle.Plain)
        {
            ViewModel = viewModel;
            Title     = "Repositories";

            _retryView = new Lazy <UIView>((() =>
                                            new RetryListView(Octicon.Repo.ToEmptyListImage(), "Error loading repositories.", LoadData)));
        }
        public static RepositoriesViewController CreateWatchedViewController()
        {
            var viewModel = RepositoriesViewModel.CreateWatchedViewModel();

            return(new RepositoriesViewController(viewModel)
            {
                Title = "Watched"
            });
        }
Beispiel #8
0
        public RepositoriesViewController(RepositoriesViewModel viewModel)
        {
            ShowOwner         = false;
            EnableFilter      = true;
            Title             = "Repositories".t();
            SearchPlaceholder = "Search Repositories".t();
            NoItemsText       = "No Repositories".t();
            ViewModel         = viewModel;

            BindCollection(ViewModel.Repositories, CreateElement);
        }
Beispiel #9
0
 public IActionResult Index(string username)
 {
     try
     {
         RepositoriesViewModel repoViewModel = GetRepoViewModel(username);
         if (repoViewModel != null)
         {
             return(View(GetRepoViewModel(username)));
         }
         else
         {
             return(View("Error"));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest($"Error getting gitData from github: {ex.Message}"));
     }
 }
Beispiel #10
0
        public ActionResult AddBookMarks(RepositoryModel Bookmark)
        {
            try
            {
                if (repositories == null)
                {
                    repositories = new RepositoriesViewModel();
                    repositories.Repositories = new List <RepositoryModel>();
                }
                //add new bookmark to Repostories list
                repositories.Repositories.Add(Bookmark);

                //save list to session
                HttpContext.Session.SetObject("repos", repositories);
            }
            catch (Exception)
            {
                throw;
            }


            return(View());
        }
        public static RepositoriesViewController CreateOrganizationViewController(string org)
        {
            var viewModel = RepositoriesViewModel.CreateOrganizationViewModel(org);

            return(new RepositoriesViewController(viewModel));
        }
        public static RepositoriesViewController CreateUserViewController(string username)
        {
            var viewModel = RepositoriesViewModel.CreateUsersViewModel(username);

            return(new RepositoriesViewController(viewModel));
        }
        public static RepositoriesViewController CreateMineViewController()
        {
            var viewModel = RepositoriesViewModel.CreateMineViewModel();

            return(new RepositoriesViewController(viewModel));
        }