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

namespace Dao.Implement
{
    public class HostUpdateRepository : RepositoryBase<HostUpdate>, IHostUpdateRepository
    {
        public IQueryable<HostUpdate> 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 HostUpdate Get(string md5, int hotelID)
        {
            return LoadAll().FirstOrDefault(r => r.Md5 == md5 && r.HotelID == hotelID);
        }
    }
}
