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

namespace Service.Implement
{
    public class RoomTypeSceneManager : GenericManagerBase<RoomTypeScene>, IRoomTypeSceneManager
    {
        public IRoomTypeModalRepository RoomTypeModalRepository { get; set; }

        public IList<RoomTypeScene> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
        {
            return ((IRoomTypeSceneRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, hotelID).ToList();
        }

        public IList<RoomTypeScene> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID, int roomTypeId)
        {
            return ((IRoomTypeSceneRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, hotelID, roomTypeId).ToList();
        }

        public IList<RoomTypeModal> LoadLights(RoomType roomType)
        {
            return RoomTypeModalRepository.LoadAll().Where(r => r.RoomType == roomType).ToList();// && (r.Type == DeviceType.Light || r.Type == DeviceType.LightDimmer)).ToList();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="roomType"></param>
        /// <param name="name">中文名，英文名和别名</param>
        /// <returns></returns>
        public RoomTypeScene Get(RoomType roomType, string name)
        {
            return CurrentRepository.LoadAll().FirstOrDefault(r => r.RoomType == roomType && (r.Name.Contains(name) || r.EnglishName.Contains(name) || r.AliasName.Contains(name)));
        }

        public RoomTypeScene Get(RoomType roomType, int sceneID)
        {
            return CurrentRepository.LoadAll().FirstOrDefault(r => r.RoomType == roomType && r.ID == sceneID);
        }
    }
}
