public async Task <ActionResult> Create(ReviewCreateViewModel reviewCreateViewModel)
        {
            var prd = _repository.PullRequestsDataManager.Get(p => p.Id == reviewCreateViewModel.PullRequestDataId);
            var pullRequestManager = await GitHubInstance.GetClientInstance().
                                     GetExistPullRequestManagerAsync(prd.RepositoryName, prd.PullRequestNumber);

            await pullRequestManager.ReviewRepository.
            CreateReviewAsync(reviewCreateViewModel.Body, reviewCreateViewModel.ReviewComments, reviewCreateViewModel.ReviewEvent);

            return(RedirectToAction("Index", "PullRequest", new
            {
                pullRequestDataId = reviewCreateViewModel.PullRequestDataId
            }));
        }
Esempio n. 2
0
        public async Task <ActionResult> Index(long pullRequestDataId)
        {
            var prd         = _repository.PullRequestsDataManager.Get(p => p.Id == pullRequestDataId);
            var pullRequest = (await GitHubInstance.GetClientInstance().
                               GetExistPullRequestManagerAsync(prd.RepositoryName,
                                                               prd.PullRequestNumber))
                              .PullRequest;

            return(View(new PullRequestViewModel
            {
                PullRequest = pullRequest,
                MentorId = prd.MentorId,
                PullRequestDataId = pullRequestDataId,
                HomeworkId = prd.HomeworkId,
                OwnerId = prd.StudentId
            }));
        }
Esempio n. 3
0
        public async Task <ActionResult> Create(PullRequestCreateViewModel pullRequestModel)
        {
            if (ModelState.IsValid)
            {
                var pullRequest = (await GitHubInstance.GetClientInstance().
                                   GetNewPullRequestManagerAsync(pullRequestModel.Title, pullRequestModel.RepositoryName,
                                                                 pullRequestModel.HeadBranchName, pullRequestModel.BaseBranchName)).PullRequest;

                var id = await CreateHomeworkViaPullRequest(pullRequestModel.TaskId, pullRequestModel.RepositoryName, pullRequest.Number);

                return(id.HasValue ? RedirectToAction("Index", new { pullRequestDataId = id })
                                                                   : RedirectToAction("Index", "Home", new { errorMessage = "Ошибка при обновлении базы данных" }));
            }
            else
            {
                ViewBag.Repos = await GitHubInstance.GetStorageInstance().GetRepositoriesAsync();

                return(PartialView(pullRequestModel));
            }
        }