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);
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)); }
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); }