コード例 #1
0
        public override async Task <SaveCommentReply> SaveComment(SaveCommentRequest request, ServerCallContext context)
        {
            var comment         = _mapper.Map <Comment>(request.Comment);
            var responseComment = await _commentService.SaveCommentAsync(comment);

            return(new SaveCommentReply
            {
                Comment = _mapper.Map <CommentMessage>(responseComment)
            });
        }
コード例 #2
0
        public async Task <Comment> SaveCommentAsync(Comment comment)
        {
            var request = new SaveCommentRequest
            {
                Comment = _mapper.Map <CommentMessage>(comment)
            };
            var reply = await _client.SaveCommentAsync(request);

            return(_mapper.Map <Comment>(reply.Comment));
        }
コード例 #3
0
        public CommentsResponse SaveComment(VmrSaveCommentViewModel model)
        {
            var modelSave = new SaveCommentRequest
            {
                InstanceId = model.InstanceId,
                Model      = model
            };

            return(_commentService.SaveComment(modelSave));
        }
コード例 #4
0
        public async Task <IActionResult> SaveComment([FromBody] SaveCommentRequest req)
        {
            Logger.LogInformation($"Get product comments with filter: ProductCode={req?.ProductCode}");

            int?productId = await Service.GetId(req?.ProductCode).ConfigureAwait(false);

            if (!productId.HasValue)
            {
                return(NotFound($"ProductCode={req?.ProductCode}"));
            }

            var comment = new CommentDto
            {
                Description = req.Description,
                PosterName  = req.PosterName,
                ProductId   = productId.Value,
                Rating      = req.Rating
            };

            await Service.SaveComment(comment).ConfigureAwait(false);

            return(Ok());
        }