网站首页 网站源码
website
站点相关全部源代码,隐藏了一些关于服务器的信息
using System.Threading;
using Dpz.Core.Public.ViewModel.RequestEvent;

namespace Dpz.Core.Service.Event;

public class AddCommentCountEvent(IRepository<Video> repository, ICommentService service)
    : IRequestHandler<AddCommentCountRequest>
{
    public async Task Handle(AddCommentCountRequest request, CancellationToken cancellationToken)
    {
        if (request.CommentType != CommentNode.Video)
        {
            return;
        }

        var count = await service.GetCommentCountAsync(request.CommentType, request.Relation);
        var update = Builders<Video>.Update.Set(x => x.CommentCount, count + 1);
        await repository.UpdateAsync(x => x.Id == request.Relation, update);
    }
}
loading