using Edu.Common.Enum;
using Edu.Model.Entity.User;
using Edu.Model.ViewModel.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Edu.Repository.User
{
    /// <summary>
    /// 学生订单旅客关联仓储层
    /// </summary>
    public class RB_Student_OrderGuestRepository : BaseRepository<RB_Student_OrderGuest>
    {
        /// <summary>
        /// 获取员工订单旅客关联列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Student_OrderGuest_ViewModel> GetStrOrderGuestListRepository(RB_Student_OrderGuest_ViewModel query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@" 
SELECT *
FROM RB_Student_OrderGuest
WHERE 1=1 
");
            builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.Status), (int)DateStateEnum.Normal);
            if (query != null)
            {
                if (query.ClassId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.ClassId), query.ClassId);
                }
                if (query.OrderId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.OrderId), query.OrderId);
                }
                if (query.GuestId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.GuestId), query.GuestId);
                }
                if (query.Student_Id > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.Student_Id), query.Student_Id);
                }
                if (query.Account_Id > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_OrderGuest_ViewModel.Account_Id), query.Account_Id);
                }
            }
            return Get<RB_Student_OrderGuest_ViewModel>(builder.ToString()).ToList();
        }
    }
}
