using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using JuSNS.Factory;
using JuSNS.Model;
using JuSNS.Config;

namespace JuSNS.Home
{
    public class HomeIndex
    {
        JuSNS.Factory.IHomeIndex dal;
        public HomeIndex()
        {
            dal = DataAccess.CreateHomeIndex();
        }

        /// <summary>
        /// 获取好友请求数量
        /// </summary>
        /// <param name="UserID">被请求的用户ID</param>
        /// <returns></returns>
        public int FriendRequest(int UserID, int Type)
        {
            return dal.FriendRequest(UserID, Type);
        }

        /// <summary>
        /// 获取通知数量（未读）
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public int NoticeInfo(int UserID)
        {
            return dal.NoticeInfo(UserID);
        }

        /// <summary>
        /// 获取10天内即将过生日的好友
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public DataTable FriendBirthday(int UserID)
        {
            return dal.FriendBirthday(UserID);
        }

        /// <summary>
        /// 得到电影图片
        /// </summary>
        /// <param name="MovieID"></param>
        /// <returns></returns>
        public string GetMoviePic(int MovieID)
        {
            return dal.GetMoviePic(MovieID);
        }
        /// <summary>
        /// 拜访与被拜访
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="boundNum">必须大于这个数量才返回相应的数据</param>
        /// <param name="topNum">获取数量</param>
        /// <returns></returns>
        public List<VisitInfo>[] Visit(int userId, int boundNum, int topNum)
        {
            return dal.Visit(userId, boundNum, topNum);
        }

        public List<UserInfo>[] FindFriend(int userId,int Sex)
        {
            return dal.FindFriend(userId, Sex);
        }


        public List<UserInfo>[] FindNewReg(int userId, int Sex, int Num)
        {
            return dal.FindNewReg(userId, Sex, Num);
        }


        /// <summary>
        /// 打招呼
        /// </summary>
        /// <param name="UserID">被打招呼的人</param>
        public IDataReader GetPoke(int UserID)
        {
            return dal.GetPoke(UserID);
        }

        /// <summary>
        /// 更新打招呼状态
        /// </summary>
        /// <param name="fID">好友ID</param>
        /// <param name="uID">用户ID</param>
        /// <param name="Flag">0回复，1忽略</param>
        public void UpdatePoke(int fID, int uID, int Flag)
        {
            dal.UpdatePoke(fID, uID, Flag);
        }


        /// <summary>
        /// 取得某用户的动态
        /// </summary>
        public List<UserLogInfo> DynList(int UserID)
        {
            int dynNum = 30;
            try
            {
                dynNum = int.Parse(JuSNS.Common.Public.GetXMLValue("dynNumber"));
            }
            catch { }
            return dal.DynList(UserID, dynNum, string.Empty, 0);
        }

        /// <summary>
        /// 取得某用户的动态
        /// </summary>
        public List<UserLogInfo> DynList(int UserID,string dyNType)
        {
            int dynNum = 30;
            try
            {
                dynNum = int.Parse(JuSNS.Common.Public.GetXMLValue("dynNumber"));
            }
            catch { }
            return dal.DynList(UserID, dynNum, dyNType, 0);
        }

        /// <summary>
        /// 取得动态(某个人的)
        /// </summary>
        public List<UserLogInfo> DynlistID(int UserID, int dynNum, string dyNType)
        {
            return dal.DynList(UserID, dynNum, dyNType, 1);
        }        

    }
}