Exemple #1
0
        private async Task <ReviewModel> GetBaseLineReview(string Language, string packageName, PullRequestModel pullRequestModel, bool forceBaseline = false)
        {
            // Get  previously cloned review for this pull request or automatically generated master review for package
            ReviewModel review = null;

            // Force baseline is passed when we need to refresh revision 0 with API revision from main branch(Automatic review revision)
            // If API review is not created for PR then also fetch review from main branch.
            if (forceBaseline || pullRequestModel.ReviewId == null)
            {
                var autoReview = await _reviewsRepository.GetMasterReviewForPackageAsync(Language, packageName);

                if (autoReview != null)
                {
                    review        = CloneReview(autoReview);
                    review.Author = pullRequestModel.Author;
                }
            }

            // If either automatic baseline is not available or if review is already created for PR then return this review to create new revision.
            if (review == null && pullRequestModel.ReviewId != null)
            {
                review = await _reviewsRepository.GetReviewAsync(pullRequestModel.ReviewId);
            }

            return(review);
        }
Exemple #2
0
        private async Task <ReviewModel> GetBaseLineReview(string Language, string packageName, PullRequestModel pullRequestModel, bool forceBaseline = false)
        {
            // Get  previously cloned review for this pull request or automatically generated master review for package
            ReviewModel review;

            if (pullRequestModel.ReviewId != null && !forceBaseline)
            {
                review = await _reviewsRepository.GetReviewAsync(pullRequestModel.ReviewId);
            }
            else
            {
                var autoReview = await _reviewsRepository.GetMasterReviewForPackageAsync(Language, packageName);

                review        = CloneReview(autoReview);
                review.Author = pullRequestModel.Author;
            }
            return(review);
        }
        public async Task DeleteReviewAsync(ClaimsPrincipal user, string id)
        {
            var reviewModel = await _reviewsRepository.GetReviewAsync(id);

            await AssertOwnerAsync(user, reviewModel);

            await _reviewsRepository.DeleteReviewAsync(reviewModel);

            foreach (var revision in reviewModel.Revisions)
            {
                foreach (var file in revision.Files)
                {
                    if (file.HasOriginal)
                    {
                        await _originalsRepository.DeleteOriginalAsync(file.ReviewFileId);
                    }

                    await _codeFileRepository.DeleteCodeFileAsync(revision.RevisionId, file.ReviewFileId);
                }
            }

            await _commentsRepository.DeleteCommentsAsync(id);
        }
        public async Task NotifySubscribersOnComment(ClaimsPrincipal user, CommentModel comment)
        {
            ReviewModel review = await _reviewRepository.GetReviewAsync(comment.ReviewId);

            await SendEmailsAsync(review, user, GetPlainTextContent(comment), GetHtmlContent(comment, review));
        }