Skip to content

Commit

Permalink
Add Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisnabi committed Jul 19, 2024
1 parent d595408 commit 2fb84a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ public async Task<MakeCommentCommandResponse> Handle(MakeCommentCommand request,
var approveLink = ApproveLink.Create(link, DateTime.UtcNow.AddHours(ApplicationSettings.ApproveLink.ExpairationOnHours));

var comment = Comment.Create(request.ArticleId, request.Client, request.Content, approveLink);
comment.RaiseMakeCommentEvent();

await _commentRepository.CreateAsync(comment, cancellationToken);
await _commentRepository.SaveChangesAsync(cancellationToken);




var content = EmailTemplates.GetConfirmEngagementEmail( request.Client.FullName, approveLink.ToString());
await emailService.SendAsync(request.Client.Email,
ApplicationSettings.ApproveLink.ConfirmEmailSubject,
Expand Down
6 changes: 6 additions & 0 deletions src/Blogger.Domain/CommentAggregate/Comment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ public ReplyId ApproveReply(string link)

return reply.Id;
}

public void RaiseMakeCommentEvent()
{
var makeCommnetEvent = new MakeCommentEvent { CommentId = Id };
AddEvent(makeCommnetEvent);
}
}
8 changes: 8 additions & 0 deletions src/Blogger.Domain/CommentAggregate/MakeCommentEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Blogger.Domain.CommentAggregate;

public class MakeCommentEvent : IDomainEvent
{
public DateTime OccurredOn => DateTime.UtcNow;

public CommentId CommentId { get; set; } = null!;
}

0 comments on commit 2fb84a1

Please sign in to comment.