using Abp.BackgroundJobs;
using Abp.Dependency;
using Abp.Domain.Repositories;

namespace YGNT.QuestionLibrary.Core.Tasks.Domain.Jobs
{
    public class QuestionReplaceTaskJob : BackgroundJob<long>, ITransientDependency
    {
        private readonly IQuestionConvertManager _questionConvertManager;
        private readonly IRepository<QuestionReplaceTask, long> _questionReplaceTaskRepository;

        public QuestionReplaceTaskJob(IQuestionConvertManager questionConvertManager, IRepository<QuestionReplaceTask, long> questionReplaceTaskRepository)
        {
            _questionConvertManager = questionConvertManager;
            _questionReplaceTaskRepository = questionReplaceTaskRepository;
        }

        public override void Execute(long args)
        {
            var task = _questionReplaceTaskRepository.FirstOrDefault(x => x.Id == args);
            if (task != null)
                _questionConvertManager.QuestionReplace(task);
        }
    }
}