using System.Threading;
using Dpz.Core.Public.ViewModel.RequestEvent;
namespace Dpz.Core.Service.Event;
public class AddDanmakuCountEvent(IRepository<Video> repository, IBarrageService barrageService)
: IRequestHandler<AddDanmakuCountRequest>
{
public async Task Handle(AddDanmakuCountRequest request, CancellationToken cancellationToken)
{
var count = await barrageService.GetGroupBarrageCountAsync(request.DanmakuGroup);
var update = Builders<Video>.Update.Set(x => x.DanmakuCount, count + 1);
await repository.UpdateAsync(x => x.Id == request.DanmakuGroup, update);
}
}