Пример #1
0
        public ReviewResponseInfoDto SendReviewResponse(ReviewResponseCreateDto reviewResponseCreateDto)
        {
            ReviewRequest request = _context
                                    .ReviewRequests
                                    .Include(s => s.ProjectInfo)
                                    .ThenInclude(p => p.Skills)
                                    .Include(s => s.User)
                                    .FirstOrDefault(r => r.Id == reviewResponseCreateDto.ReviewRequestId);

            if (request == null)
            {
                throw RecademyException.ReviewRequestNotFound(reviewResponseCreateDto.ReviewRequestId);
            }

            if (request.State == ProjectState.Completed || request.State == ProjectState.Abandoned)
            {
                throw new RecademyException("Failed to send review. It is already closed.");
            }

            var newReview = new ReviewResponse
            {
                ReviewRequestId  = reviewResponseCreateDto.ReviewRequestId,
                Description      = reviewResponseCreateDto.ReviewText,
                ReviewerId       = reviewResponseCreateDto.UserId,
                CreationTime     = DateTime.UtcNow,
                ReviewConclusion = reviewResponseCreateDto.ReviewConclusion
            };

            request.State = ProjectState.Reviewed;
            _context.ReviewResponses.Add(newReview);
            _context.SaveChanges();

            newReview.ReviewRequest = request;
            return(new ReviewResponseInfoDto(newReview));
        }
Пример #2
0
        public TestCaseContext WithReviewResponse(ReviewRequestInfoDto reviewRequest, int userId, out ReviewResponseInfoDto reviewResponse)
        {
            ReviewResponseCreateDto createDto = InstanceFactory.CreateReviewResponseCreateDto(userId, reviewRequest.Id);

            reviewResponse = ReviewResponseController.CreateReviewResponse(createDto).Value;

            Assert.NotNull(reviewResponse);

            return(this);
        }