Exemplo n.º 1
0
        public OrganizationViewModel(IApplicationService applicationService)
        {
            GoToMembersCommand = ReactiveCommand.Create();
            GoToMembersCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel <OrganizationMembersViewModel>();
                vm.OrganizationName = Name;
                ShowViewModel(vm);
            });

            GoToTeamsCommand = ReactiveCommand.Create();
            GoToTeamsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel <TeamsViewModel>();
                vm.OrganizationName = Name;
                ShowViewModel(vm);
            });

            GoToFollowersCommand = ReactiveCommand.Create();
            GoToFollowersCommand.Subscribe(_ =>
            {
                var vm      = CreateViewModel <UserFollowersViewModel>();
                vm.Username = Name;
                ShowViewModel(vm);
            });

            GoToEventsCommand = ReactiveCommand.Create();
            GoToEventsCommand.Subscribe(_ =>
            {
                var vm      = CreateViewModel <UserEventsViewModel>();
                vm.Username = Name;
                ShowViewModel(vm);
            });

            GoToGistsCommand = ReactiveCommand.Create();
            GoToGistsCommand.Subscribe(_ =>
            {
                var vm      = CreateViewModel <UserGistsViewModel>();
                vm.Username = Name;
                ShowViewModel(vm);
            });

            GoToRepositoriesCommand = ReactiveCommand.Create();
            GoToRepositoriesCommand.Subscribe(_ =>
            {
                var vm  = CreateViewModel <OrganizationRepositoriesViewModel>();
                vm.Name = Name;
                ShowViewModel(vm);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
                                                          this.RequestModel(applicationService.Client.Organizations[Name].Get(), t as bool?,
                                                                            response => Organization = response.Data));
        }
Exemplo n.º 2
0
        public OrganizationViewModel(ISessionService applicationService)
        {
            this.WhenAnyValue(x => x.Organization, x => x.Username,
                              (x, y) => x == null ? y : (string.IsNullOrEmpty(x.Name) ? x.Login : x.Name))
            .Select(x => x ?? "Organization")
            .Subscribe(x => Title = x);

            this.WhenAnyValue(x => x.Organization.AvatarUrl)
            .Select(x => new GitHubAvatar(x))
            .ToProperty(this, x => x.Avatar, out _avatar);

            GoToMembersCommand = ReactiveCommand.Create();
            GoToMembersCommand
            .Select(_ => this.CreateViewModel <OrganizationMembersViewModel>())
            .Select(x => x.Init(Username))
            .Subscribe(NavigateTo);

            GoToTeamsCommand = ReactiveCommand.Create();
            GoToTeamsCommand
            .Select(_ => this.CreateViewModel <TeamsViewModel>())
            .Select(x => x.Init(Username))
            .Subscribe(NavigateTo);

            GoToFollowersCommand = ReactiveCommand.Create();
            GoToFollowersCommand
            .Select(_ => this.CreateViewModel <UserFollowersViewModel>())
            .Select(x => x.Init(Username))
            .Subscribe(NavigateTo);

            GoToFollowingCommand = ReactiveCommand.Create();
            GoToFollowingCommand
            .Select(_ => this.CreateViewModel <UserFollowingsViewModel>())
            .Select(x => x.Init(Username))
            .Subscribe(NavigateTo);

            GoToEventsCommand = ReactiveCommand.Create();
            GoToEventsCommand
            .Select(_ => this.CreateViewModel <UserEventsViewModel>())
            .Select(x => x.Init(Username))
            .Subscribe(NavigateTo);

            GoToGistsCommand = ReactiveCommand.Create();
            GoToGistsCommand
            .Select(_ => this.CreateViewModel <UserGistsViewModel>())
            .Select(x => x.Init(Username))
            .Subscribe(NavigateTo);

            GoToRepositoriesCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm  = this.CreateViewModel <OrganizationRepositoriesViewModel>();
                vm.Name = Username;
                NavigateTo(vm);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ =>
            {
                applicationService.GitHubClient.Organization.Team.GetAll(Username)
                .ToBackground(x => CanViewTeams = true);

                Organization = await applicationService.GitHubClient.Organization.Get(Username);
            });
        }