Ejemplo n.º 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);
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }