using Edu.Common.Enum;
using Edu.Model.Entity.Scroll;
using Edu.Model.ViewModel.Scroll;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;

namespace Edu.Repository.Scroll
{
    /// <summary>
    /// 滚动开班班次仓储层
    /// </summary>
    public class RB_Scroll_ShiftRepository : BaseRepository<RB_Scroll_Shift>
    {

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="demodel"></param>
        /// <returns></returns>
        public List<RB_Scroll_Shift_ViewModel> GetList(RB_Scroll_Shift_ViewModel demodel)
        {
            DynamicParameters parameters = new DynamicParameters();
            string where = $@" 1=1 and r.{nameof(RB_Scroll_Shift_ViewModel.Status)} =0";
            if (demodel.Group_Id > 0)
            {
                where += $@" and r.{nameof(RB_Scroll_Shift_ViewModel.Group_Id)} ={demodel.Group_Id}";
            }
            if (demodel.Id > 0)
            {
                where += $@" and r.{nameof(RB_Scroll_Shift_ViewModel.Id)} ={demodel.Id}";
            }
            if (!string.IsNullOrEmpty(demodel.Name))
            {
                where += $@" and r.{nameof(RB_Scroll_Shift_ViewModel.Name)} like @Name";
                parameters.Add("Name", "%" + demodel.Name + "%");
            }

            string sql = $@" 
SELECT * From RB_Scroll_Shift r
WHERE {where} 
ORDER BY r.Id asc ";
            return Get<RB_Scroll_Shift_ViewModel>(sql, parameters).ToList();
        }
    }
}
