namespace Tiobon.Core.Services;

/// <summary>
/// 开班费用 (服务)
/// </summary>
public class Ghre_OpenClassFeeServices : BaseServices<Ghre_OpenClassFee, Ghre_OpenClassFeeDto, InsertGhre_OpenClassFeeInput, EditGhre_OpenClassFeeInput>, IGhre_OpenClassFeeServices
{
    private readonly IBaseRepository<Ghre_OpenClassFee> _dal;
    public Ghre_OpenClassFeeServices(ICaching caching, IBaseRepository<Ghre_OpenClassFee> dal)
    {
        this._dal = dal;
        base.BaseDal = dal;
        base._caching = caching;
    }

    public override async Task<ServicePageResult<Ghre_OpenClassFeeDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true)
    {


        var result = await base.QueryFilterPage(filter, condition, IsEnable);

        for (int i = 0; i < result.result.DT_TableDataT1.Count; i++)
        {
            var DT_TableDataT1 = result.result.DT_TableDataT1[i];

            //DT_TableDataT1.Source = DT_TableDataT1.Source == "Backend" ? "后台新增" : "报名";
            DT_TableDataT1.ItemCode = await GetParaLabel("TrainOpenClassFee", result.result.DT_TableDataT1[i].ItemCode);
            if (DT_TableDataT1.StaffId != null)
                DT_TableDataT1.StaffName = await Db.Queryable<Ghra_Staff>().Where(x => x.StaffID == DT_TableDataT1.StaffId).Select(x => x.StaffName).FirstAsync();
            result.result.DT_TableDataT1[i] = DT_TableDataT1;
        }
        return result;
    }
}