using YBEE.EQM.Core;

namespace YBEE.EQM.Application;

/// <summary>
/// 高中选科组合管理服务
/// </summary>
public class NceeCourseCombService : INceeCourseCombService, ITransient
{
    private readonly IRepository<NceeCourseComb> _rep;
    public NceeCourseCombService(IRepository<NceeCourseComb> rep)
    {
        _rep = rep;
    }

    /// <summary>
    /// 根据ID获取高中选科组合
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public async Task<NceeCourseCombOutput> GetById(short id)
    {
        var item = await _rep.DetachedEntities.FirstOrDefaultAsync(x => x.Id == id);
        return item.Adapt<NceeCourseCombOutput>();
    }
    /// <summary>
    /// 获取所有高中选科组合
    /// </summary>
    /// <returns></returns>
    public async Task<List<NceeCourseCombOutput>> GetAllList()
    {
        var items = await _rep.DetachedEntities.ProjectToType<NceeCourseCombOutput>().ToListAsync();
        return items;
    }
}
