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

namespace Dao.Implement
{
    public class HostRCURepository : RepositoryBase<HostRCU>, IHostRCURepository
    {
        public IQueryable<HostRCU> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
        {
            var list = this.LoadAll().Where(r => r.HotelID == hotelID);

            total = list.LongCount();

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

            return list;
        }

        public HostRCU GetByHostID(int hostID)
        {
            return this.LoadAll().Where(r => r.HostID == hostID).FirstOrDefault();
        }

        public List<HostRCU> LoadAll(int hotelID)
        {
            return this.LoadAll().Where(r => r.HotelID == hotelID).ToList();
        }
    }
}
