コード例 #1
0
        public ActionResult ReplyToComment(ReplyToProductCommentCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("ReplyToComment"));
            }
            command.UserId = CurrentUser.Id;
            var result = _commandBus.Send(command);

            return(JsonMessage(result));
        }
コード例 #2
0
        public ICommandResult Execute(ReplyToProductCommentCommand command)
        {
            try
            {
                if (command == null)
                {
                    throw new ArgumentNullException();
                }

                var comment = _productCommentRepository.GetById(command.CommentId);
                comment.ParentId = command.ProductId; //ToDo
                comment.Body     = command.Body;
                _productCommentRepository.Edit(comment);
                _unitOfWork.Commit();

                return(new SuccessResult(ProductCommandMessage.ProductCommentCreatedSuccessufully));
            }
            catch (Exception exception)
            {
                _logger.Error(exception.Message);
                return(new FailureResult(ProductCommandMessage.ProductCommentCreationFailed));
            }
        }