using System.Threading.Tasks;
using Abp.Dependency;
using Abp.Domain.Uow;
using Abp.Events.Bus.Entities;
using Abp.Events.Bus.Handlers;
using YGNT.QuestionLibrary.Core.Papers.Domain;

namespace YGNT.QuestionLibrary.Core.Papers.Event
{
    public class PaperDisciplineQtSortSettingHandler : ITransientDependency
        , IAsyncEventHandler<EntityChangingEventData<PaperDisciplineQtSortSetting>>
    {
        private readonly IPaperManager _paperManager;

        public PaperDisciplineQtSortSettingHandler(IPaperManager paperManager)
        {
            _paperManager = paperManager;
        }

        /// <summary>
        /// 修改排序设置后更新试题排序
        /// </summary>
        /// <param name="eventData">Event data</param>
        public async Task HandleEventAsync(EntityChangingEventData<PaperDisciplineQtSortSetting> eventData)
        {
            var sortSetting = eventData.Entity;
            await _paperManager.UpdatePaperQuestionSortAsync(sortSetting);
        }
    }
}