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.ClearPostReaction;
|
||||
|
||||
public record ClearPostReactionCommand(Guid PostId, string Emoji, Guid ReactorId): ICommand;
|
|
@ -0,0 +1,22 @@
|
|||
using Femto.Common.Domain;
|
||||
using Femto.Modules.Blog.Application.Commands.AddPostReaction;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Femto.Modules.Blog.Application.Commands.ClearPostReaction;
|
||||
|
||||
internal class ClearPostReactionCommandHandler(BlogContext context)
|
||||
: ICommandHandler<ClearPostReactionCommand>
|
||||
{
|
||||
public async Task Handle(ClearPostReactionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var post = await context.Posts.SingleOrDefaultAsync(
|
||||
p => p.Id == request.PostId,
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
if (post is null)
|
||||
return;
|
||||
|
||||
post.RemoveReaction(request.ReactorId, request.Emoji);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue