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

namespace Dao.Implement
{
    public class AppRoomRepository : RepositoryBase<AppRoom>, IAppRoomRepository
    {
        public IQueryable<AppRoom> 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 bool isExistMac(string mac)
        {
            int count = this.LoadAll().Where(f => f.MAC == mac).Count();

            if (count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        public AppRoom GetRoomNumber(string mac)
        {
            return this.LoadAll().FirstOrDefault(r => r.MAC == mac);
        }
    }
}
