using System.Linq;
using System.Threading.Tasks;
using Abp.Domain.Repositories;
using Microsoft.EntityFrameworkCore;

namespace YGNT.QuestionLibrary.Core.Papers.Domain
{
    public class ScoringManager : IScoringManager
    {
        private readonly IRepository<PaperQuestion, long> _paperQuestionRepository;

        public ScoringManager(IRepository<PaperQuestion, long> paperQuestionRepository)
        {
            _paperQuestionRepository = paperQuestionRepository;
        }

        /// <summary>
        /// 检查评分标准是否已经使用
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<bool> CheckIsUsedAsync(int id)
        {
            return await _paperQuestionRepository.GetAll()
                .Where(x => x.ScoringId == id)
                .AnyAsync();
        }
    }
}