コード例 #1
0
 private Comment Map(CommentRecord rec) => factory.Create(
     rec.Id,
     rec.UserId,
     rec.PostId,
     rec.ParentId,
     rec.Body,
     new VoteStats(rec.Upvotes, rec.Downvotes), rec.CreationDate, rec.WasUpdated, rec.WasDeleted);
コード例 #2
0
ファイル: CommentCreator.cs プロジェクト: csf-dev/agiil
        public CreateCommentResponse Create(CreateCommentRequest request)
        {
            var validator        = validatorFactory.GetValidator();
            var validationResult = validator.Validate(request);

            if (!validationResult.IsSuccess)
            {
                return(responseCreator(validationResult, null));
            }

            Comment comment;

            using (var tran = transactionCreator.GetTransaction())
            {
                var ticket = ticketRepo.Get(request.TicketId);
                comment = commentFactory.Create(request.Body);
                ticket.Comments.Add(comment);

                ticketRepo.Update(ticket);
                commentRepo.Add(comment);

                tran.Commit();
            }

            return(responseCreator(validationResult, comment));
        }
コード例 #3
0
ファイル: CommentService.cs プロジェクト: maoyuan121/Updog.in
        public async Task <Comment> Create(CommentCreate create, User user)
        {
            Comment c = factory.Create(create, user);
            await repo.Add(c);

            await bus.Dispatch(new CommentCreateEvent(c));

            return(c);
        }