post reactions
This commit is contained in:
parent
d1687f276b
commit
8e8e4e2258
10 changed files with 124 additions and 8 deletions
|
@ -0,0 +1,6 @@
|
|||
using Femto.Common;
|
||||
using Femto.Common.Domain;
|
||||
|
||||
namespace Femto.Modules.Blog.Application.Commands.AddPostReaction;
|
||||
|
||||
public record AddPostReactionCommand(Guid PostId, string Emoji, Guid ReactorId) : ICommand;
|
|
@ -0,0 +1,21 @@
|
|||
using Femto.Common.Domain;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Femto.Modules.Blog.Application.Commands.AddPostReaction;
|
||||
|
||||
internal class AddPostReactionCommandHandler(BlogContext context)
|
||||
: ICommandHandler<AddPostReactionCommand>
|
||||
{
|
||||
public async Task Handle(AddPostReactionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var post = await context.Posts.SingleOrDefaultAsync(
|
||||
p => p.Id == request.PostId,
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
if (post is null)
|
||||
return;
|
||||
|
||||
post.AddReaction(request.ReactorId, request.Emoji);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue