public async Task PullRequestReview(DateTimeOffset eventDate, PullRequestReviewPayload payload) { // GitHub sends pending reviews that they shouldn't. We don't want them. if (payload.Review.State.Equals("pending", StringComparison.OrdinalIgnoreCase)) { this.Info($"Dropping pending review. {payload.Repository.FullName}#{payload.Review.Id}"); return; } var updater = new DataUpdater(_contextFactory, _mapper); await updater.UpdateRepositories(eventDate, new[] { payload.Repository }); await updater.UpdatePullRequests(payload.Repository.Id, eventDate, new[] { payload.PullRequest }); switch (payload.Action) { case "submitted": case "edited": // We need the issueId // TODO: Modify BulkUpdate to work with PR/Issue Number instead? long?issueId; using (var context = _contextFactory.CreateInstance()) { issueId = await context.Issues .AsNoTracking() .Where(x => x.RepositoryId == payload.Repository.Id && x.Number == payload.PullRequest.Number) .Select(x => (long?)x.Id) .SingleOrDefaultAsync(); } if (issueId != null) { await updater.UpdateReviews(payload.Repository.Id, issueId.Value, eventDate, new[] { payload.Review }); } break; case "dismissed": await updater.DeleteReview(payload.Review.Id); break; default: throw new NotImplementedException($"Action '{payload.Action}' is not valid for event {nameof(PullRequestReview)}."); } await updater.Changes.Submit(_queueClient); }