using System;
using System.Collections.Generic;
using System.Linq;
using Abp.Application.Services;
using Abp.Domain.Repositories;
using Abp.Extensions;
using Abp.Localization;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http.Extensions;
using YGNT.QuestionLibrary.BaseDatas.Dto;
using YGNT.QuestionLibrary.Core.BaseData;
using YGNT.QuestionLibrary.Core.Models;
using YGNT.QuestionLibrary.Core.Questions;
using YGNT.QuestionLibrary.Core.Tasks.Domain;

namespace YGNT.QuestionLibrary.BaseDatas
{
    /// <summary>
    /// 试题基础数据
    /// </summary>
    public class QuestionBaseDataAppService : ApplicationService, IQuestionBaseDataAppService
    {
        private readonly ILocalizationManager _localizationManager;
        private readonly IRepository<QuestionOrigin, long> _questionOriginRepository;
        private readonly IQuestionConvertManager _questionConvertManager;

        public QuestionBaseDataAppService(ILocalizationManager localizationManager, IServerAddressesFeature addresses, IRepository<QuestionOrigin, long> questionOriginRepository, IQuestionConvertManager questionConvertManager)
        {
            _localizationManager = localizationManager;
            _questionOriginRepository = questionOriginRepository;
            _questionConvertManager = questionConvertManager;
        }

        /// <summary>
        /// 获取难度列表
        /// </summary>
        /// <returns></returns>
        public List<DifficultyDto> GetDifficulty()
        {
            var names = Enum.GetNames(typeof(Difficulty));
            var result = new List<DifficultyDto>();
            foreach (var name in names)
            {
                result.Add(new DifficultyDto()
                {
                    Name = name,
                    Value = Enum.Parse(typeof(Difficulty), name).To<int>()
                });
            }
            return result;
        }


        public void Test(long id)
        {
            var questionOrigin = _questionOriginRepository.Get(id);
            _questionConvertManager.ConvertHtmlToDoc(questionOrigin);
        }
    }
}