using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic;
using System.Text;
using Domain;

namespace Dao.Implement
{
    public class RoomTypeWXMenusRepository : RepositoryBase<RoomTypeWXMenus>, IRoomTypeWXMenusRepository
    {
        public IQueryable<RoomTypeWXMenus> LoadAllByPage(out long total, int page, int rows, string order, string sort)
        {
            var list = this.LoadAll();

            total = list.LongCount();

            list = list.OrderBy(sort + " " + order);
            list = list.Skip((page - 1) * rows).Take(rows);

            return list;
        }

        public IQueryable<RoomTypeWXMenus> LoadAll(int roomTypeID)
        {
            return this.LoadAll().Where(r => r.RoomType.ID == roomTypeID);
        }

        public void DeleteByRoomTypeID(int roomTypeID)
        {
            IList<RoomTypeWXMenus> lists = this.LoadAll(roomTypeID).ToList();
            foreach (RoomTypeWXMenus list in lists)
            {
                this.Delete(list.ID);
            }
        }
    }
}
