wip comments
This commit is contained in:
parent
cbf67bf5f1
commit
4c69c6d30d
14 changed files with 151 additions and 21 deletions
|
@ -0,0 +1,20 @@
|
|||
using Femto.Common.Domain;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Femto.Modules.Blog.Application.Commands.AddPostComment;
|
||||
|
||||
internal class AddPostCommentCommandHandler(BlogContext context) : ICommandHandler<AddPostCommentCommand>
|
||||
{
|
||||
public async Task Handle(AddPostCommentCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var post = await context.Posts.SingleOrDefaultAsync(
|
||||
p => p.Id == request.PostId,
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
if (post is null)
|
||||
return;
|
||||
|
||||
post.AddComment(request.AuthorId, request.Content);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue