Files
Yi.Framework/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/EventHandlers/SeeDiscussEventHandler.cs
2024-01-11 18:51:53 +08:00

36 lines
1009 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Shared.Etos;
namespace Yi.Framework.Bbs.Application.EventHandlers
{
public class SeeDiscussEventHandler : ILocalEventHandler<SeeDiscussEventArgs>, ITransientDependency
{
private IRepository<DiscussEntity, Guid> _repository;
public SeeDiscussEventHandler(IRepository<DiscussEntity, Guid> repository)
{
_repository = repository;
}
public async Task HandleEventAsync(SeeDiscussEventArgs eventData)
{
var entity = await _repository.GetAsync(eventData.DiscussId);
if (entity is not null)
{
entity.SeeNum += 1;
await _repository.UpdateAsync(entity);
}
}
}
}