Пример #1
0
        public async Task <ActionResult <VerificationStatus> > CreateStatus([FromBody] VerificationStatus statusDto)
        {
            await _unitOfWork.VerificationStatuses.CreateAsync(statusDto);

            await _unitOfWork.CommitAsync();

            return(NoContent());
        }
        public async Task <ActionResult <AuthorVerification> > CreateVerification([FromBody] AuthorVerification verificationDto)
        {
            await _unitOfWork.AuthorVerifications.CreateAsync(verificationDto);

            await _unitOfWork.CommitAsync();

            return(NoContent());
        }
Пример #3
0
        public async Task <ActionResult> CreateTag([FromBody] TagRequest tagDto)
        {
            var tag = _mapper.Map <Tag>(tagDto);
            await _unitOfWork.Tags.CreateAsync(tag);

            await _unitOfWork.CommitAsync();

            return(NoContent());
        }
Пример #4
0
        public async Task <RatingResponse> CreateRatingAsync(RatingRequest ratingDto, string userId)
        {
            Rating rating = _mapper.Map <Rating>(ratingDto);

            rating.UserId = userId;

            await _unitOfWork.Ratings.CreateAsync(rating);

            await _unitOfWork.CommitAsync();

            return(_mapper.Map <RatingResponse>(rating));
        }
Пример #5
0
        public async Task <CommentResponse> PublishCommentAsync(CommentRequest commentDto, string authorId)
        {
            var comment = _mapper.Map <Comment>(commentDto);

            comment.AuthorId = authorId;

            await _unitOfWork.Comments.CreateAsync(comment);

            await _unitOfWork.CommitAsync();

            var createdComment = await _unitOfWork.Comments.GetCommentWithAuthorAsync(comment.Id);

            var response = _mapper.Map <CommentResponse>(createdComment);

            this.AddRelativeTimeToResponse(response);

            return(response);
        }