using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Edu.Model.Entity.EduTask;
using Edu.Model.ViewModel.EduTask;

namespace Edu.Repository.EduTask
{
    /// <summary>
    /// 临时上课邀请记录表
    /// </summary>
    public class RB_Temporary_InvitationRepository : BaseRepository<RB_Temporary_Invitation>
    {
        /// <summary>
        /// 获取班级上课学生列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Temporary_Invitation> GetTemporaryInvitationListRepository(RB_Temporary_Invitation query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@" SELECT * FROM RB_Temporary_Invitation WHERE 1=1 ");
            if (query != null)
            {
                if (query.ClassPlanId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Temporary_Invitation.ClassPlanId), query.ClassPlanId);
                }
                if (query.ClassTimeId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Temporary_Invitation.ClassTimeId), query.ClassTimeId);
                }
                if (query.ClassId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Temporary_Invitation.ClassId), query.ClassId);
                }

                if (query.Group_Id > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Temporary_Invitation.Group_Id), query.Group_Id);
                }
                //if (query.School_Id > 0)
                //{
                //    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Temporary_Invitation.School_Id), query.School_Id);
                //}
            }
            return Get<RB_Temporary_Invitation>(builder.ToString()).ToList();
        }
    }
}
