using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Service;
using Domain;
using Common;

namespace WebSite.Controllers
{
    public class HostWordsReportController : BaseController
    {
        //private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(HostWordsReportController));
        public IHostWordsReportManager HostWordsReportManager { get; set; }
        public IHostManager HostManager { get; set; }

        #region Action

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult LoadAllByPage(int page, int rows, string order, string sort, string roomNumber)
        {
            long total = 0;
            IList<Host> lstHosts = HostManager.LoadAll(CurrentHotelID);
            IList<HostWordsReport> list = HostWordsReportManager.LoadAllByPage(out total, page, rows, order, sort, CurrentHotelID);
            var rsult = list.Select(r => new
            {
                RoomNumber = lstHosts.Where(t => t.ID == r.HostID).FirstOrDefault().RoomNumber,
                ModalAddress = r.ModalAddress,
                Type = r.Type,
                Sentence = r.Sentence,
                CreatedDate = r.CreatedDate
            });
            return Json(new { total = total, rows = rsult });
        }

        #endregion
    }
}
