Exemple #1
0
        public async Task <IActionResult> Branches(int id, int?bid)
        {
            //使用委员会主键id构建支部清单页视图模型
            var model = new BranchesViewModel();

            model.ThisCommittee = await _committeeApi.GetCommittee(id);

            ((List <Branch>)model.Branches).AddRange(
                await _committeeApi.GetBranchesInCommittee(id)
                );
            if (bid == null || bid.Value <= 0)
            {
                model.SelectedBranch = model.Branches.FirstOrDefault();
            }
            else
            {
                model.SelectedBranch = model.Branches.Where(b => b.Id == bid.Value).FirstOrDefault();
            }
            if (model.SelectedBranch != null)
            {
                //读取该支部中的所有会员
                var members = await _memberApi.GetMembersInBranch(model.SelectedBranch.Id);

                foreach (var m in members)
                {
                    model.Members.Add(m);
                }
            }
            return(View(model));
        }
Exemple #2
0
 public BranchPage(BranchesViewModel branch, Users user)
 {
     InitializeComponent();
     this.curr_user      = user;
     this.ViewModel      = branch;
     this.BindingContext = ViewModel;
 }
Exemple #3
0
 public IActionResult Branches(BranchesViewModel model)
 {
     return(RedirectToAction(nameof(Branches),
                             new
     {
         id = model.ThisCommittee.Id,
         bid = model.SelectedBranch.Id
     }));
 }
Exemple #4
0
 private void GoToCommits(Repository repoModel, string branch)
 {
     if (branch != null)
     {
         NavigateTo(new CommitsViewModel(repoModel.Owner, repoModel.Slug, branch));
     }
     else
     {
         NavigateTo(BranchesViewModel.ForCommits(repoModel.Owner, repoModel.Slug));
     }
 }
        public ChangesetBranchesViewController(string username, string slug)
        {
            Title             = "Changeset Branch".t();
            SearchPlaceholder = "Search Branches".t();
            NoItemsText       = "No Branches".t();
            ViewModel         = new BranchesViewModel(username, slug);

            BindCollection(ViewModel, x => x.Branches, x => {
                return(new StyledStringElement(x.Name, () => NavigationController.PushViewController(new ChangesetsViewController(ViewModel.Username, ViewModel.Repository, x.Name), true)));
            });
        }
        public async Task <IHttpActionResult> GetBranches()
        {
            BranchesViewModel list = new BranchesViewModel();

            //Listan av brancher tilldelas ett värde av branscher genom att anropa på metoden GetBranches() från repository
            list.Branches = await uw.Branches.GetBranches();

            if (list == null)
            {
                return(NotFound());
            }
            return(Ok(list));
        }
Exemple #7
0
        //Returnerar flera branscher
        public async Task <ActionResult> Branches()
        {
            BranchesViewModel bVM    = null;
            HttpClient        client = new HttpClient();

            //Gör ett api-anrop för att hämta flera branscher
            var result = client.GetAsync("http://localhost:55341/api/GetBranches/").Result;

            if (result.IsSuccessStatusCode)
            {
                bVM = await result.Content.ReadAsAsync <BranchesViewModel>();
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
            }
            return(View(bVM));
        }
        private async void Button_Clicked(object sender, EventArgs e)
        {
            branchesList.BranchesList.Clear();
            BranchesService bs = new BranchesService();

            branchSource = await bs.GetBranches();

            foreach (Branches branch in branchSource)
            {
                BranchesViewModel bvm = new BranchesViewModel
                {
                    id           = branch.id,
                    branchname   = branch.branchname,
                    description  = branch.description,
                    creator_id   = branch.creator_id,
                    created_date = branch.created_date
                };
                branchesList.BranchesList.Add(bvm);
            }
        }
Exemple #9
0
        public RepositoryViewModel(
            string username, string repositoryName, Repository repository = null,
            IApplicationService applicationService = null, IActionMenuService actionMenuService = null)
        {
            applicationService = _applicationService = applicationService ?? Locator.Current.GetService <IApplicationService>();
            actionMenuService  = actionMenuService ?? Locator.Current.GetService <IActionMenuService>();

            Repository = repository;

            _branches.Changed
            .Select(_ => _branches.Count)
            .ToProperty(this, x => x.BranchesCount, out _branchesCount);

            this.WhenAnyValue(x => x.Repository.Name)
            .StartWith(repositoryName)
            .Subscribe(x => Title = x);

            LoadCommand = ReactiveCommand.CreateFromTask(async _ => {
                Repository = await applicationService.Client.Repositories.Get(username, repositoryName);

                _applicationService.Client.Repositories.GetWatchers(username, repositoryName)
                .ToBackground(x => Watchers = x.Size);

                _applicationService.Client.Repositories.GetForks(username, repositoryName)
                .ToBackground(x => Forks = x.Size);

                _applicationService.Client.Repositories.GetBranches(username, repositoryName)
                .ToBackground(x => _branches.Reset(x));

                if (!Repository.HasIssues)
                {
                    Issues = 0;
                }
                else
                {
                    _applicationService.Client.Issues.GetAll(username, repositoryName, limit: 0)
                    .ToBackground(x => Issues = x.Count);
                }

                LoadReadme(username, repositoryName).ToBackground();
            });

            ForkCommand = ReactiveCommand.CreateFromTask(async _ => {
                var fork = await applicationService.Client.Repositories.Fork(username, repositoryName);
                NavigateTo(new RepositoryViewModel(fork.Owner, fork.Slug));
            });

            var canGoToFork = this.WhenAnyValue(x => x.Repository)
                              .Select(x => x?.Parent != null);

            GoToForkParentCommand = ReactiveCommand.Create(() => {
                var id = RepositoryIdentifier.FromFullName(Repository.Parent.FullName);
                NavigateTo(new RepositoryViewModel(id.Owner, id.Name));
            }, canGoToFork);

            GoToReadmeCommand = ReactiveCommand.Create(
                () => NavigateTo(new ReadmeViewModel(username, repositoryName, _readmeFilename)),
                this.WhenAnyValue(x => x.HasReadme));

            GoToPullRequestsCommand
            .Select(_ => new PullRequestsViewModel(username, repositoryName))
            .Subscribe(NavigateTo);

            GoToWikiCommand = ReactiveCommand.Create(
                () => NavigateTo(new WikiViewModel(username, repositoryName)),
                this.WhenAnyValue(x => x.Repository.HasWiki));

            GoToSourceCommand
            .Select(_ => new BranchesAndTagsViewModel(username, repositoryName))
            .Subscribe(NavigateTo);

            GoToIssuesCommand
            .Select(_ => new IssuesViewModel(username, repositoryName))
            .Subscribe(NavigateTo);

            GoToOwnerCommand
            .Select(_ => new UserViewModel(username))
            .Subscribe(NavigateTo);

            GoToStargazersCommand
            .Select(_ => new RepositoryWatchersViewModel(username, repositoryName))
            .Subscribe(NavigateTo);

            GoToEventsCommand
            .Select(_ => new RepositoryEventsViewModel(username, repositoryName))
            .Subscribe(NavigateTo);

            GoToBranchesCommand
            .Select(_ => BranchesViewModel.ForSource(username, repositoryName))
            .Subscribe(NavigateTo);

            var validWebsite = this.WhenAnyValue(x => x.Repository.Website)
                               .Select(x => !string.IsNullOrEmpty(x));

            GoToWebsiteCommand = ReactiveCommand.Create(
                () => NavigateTo(new WebBrowserViewModel(Repository.Website)),
                validWebsite);

            GoToCommitsCommand
            .Subscribe(_ =>
            {
                if (_branches.Count == 1)
                {
                    NavigateTo(new CommitsViewModel(username, repositoryName, _branches.FirstOrDefault()?.Node));
                }
                else
                {
                    NavigateTo(BranchesViewModel.ForCommits(username, repositoryName));
                }
            });

            ShowMenuCommand = ReactiveCommand.CreateFromTask(sender =>
            {
                var menu     = actionMenuService.Create();
                var isPinned = applicationService
                               .Account.PinnedRepositories
                               .Any(x => string.Equals(x.Owner, username, StringComparison.OrdinalIgnoreCase) && string.Equals(x.Slug, repositoryName, StringComparison.OrdinalIgnoreCase));
                var pinned = isPinned ? "Unpin from Slideout Menu" : "Pin to Slideout Menu";
                menu.AddButton(pinned, _ => PinRepository());
                menu.AddButton("Fork Repository", _ => ForkCommand.ExecuteNow());
                menu.AddButton("Show in Bitbucket", _ =>
                {
                    var htmlUrl = ("https://bitbucket.org/" + username + "/" + repositoryName).ToLower();
                    NavigateTo(new WebBrowserViewModel(htmlUrl));
                });
                return(menu.Show(sender));
            });
        }