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

namespace JuSNS.Home
{
    public class Space
    {
        private ISpace dal;
        /// <summary>
        /// 构造函数
        /// </summary>
        public Space()
        {
            dal = DataAccess.CreateSpace();
        }

        public DataTable getUserInfo(int Id,int flag)
        {
            return dal.getUserInfo(Id,flag);
        }

        public DataTable getConstellation(int flag)
        {
            return dal.getConstellation(flag);
        }

        public int UpdateUserInfo(JuSNS.Model.UserBasicInfo Info, int ID, int flag)
        {
            return dal.UpdateUserInfo(Info,ID,flag);
        }
        /// <summary>
        /// 更新会员信息可见度
        /// </summary>
        /// <param name="StrName">字段名称</param>
        /// <param name="k">值</param>
        /// <param name="UserID">会员编号</param>
        /// <returns></returns>
        public int UpdatePrivacy(string StrName, int k, int UserID)
        {
            return dal.UpdatePrivacy(StrName,k,UserID);
        }

        /// <summary>
        /// 根据相关编号删除会员相关信息
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public int DelInfo(int ID, int flag)
        {
            return dal.DelInfo(ID, flag);
        }
       
         /// <summary>
        /// 根据受教育程度和区域读学校信息
        /// </summary>
        /// <param name="AreaId">区域编号</param>
        /// <param name="DegreeID">受教育程度</param>
        /// <returns></returns>
        public DataTable getShool(int AreaId, int DegreeID)
        {
            return dal.getShool(AreaId, DegreeID);
        }

        /// <summary>
        /// 根据省份名称,地区编号和受教育程度搜索学校
        /// </summary>
        /// <param name="shoolName">省份名称</param>
        /// <param name="AreaId">地区编号</param>
        /// /// <param name="DegreeID">受教育程度</param>
        /// <returns></returns>
        public DataTable searchShool(string shoolName, int AreaId, int DegreeID)
        {
            return dal.searchShool(shoolName, AreaId, DegreeID);
        }

        /// <summary>
        /// 添加会员教育信息
        /// </summary>
        /// <param name="Info"></param>
        /// <param name="ID"></param>
        /// <returns></returns>
        public int AddEducationInfo(JuSNS.Model.UserEducationInfo Info, int ID)
        {
            return dal.AddEducationInfo(Info,ID);
        }

        /// <summary>
        /// 添加更新会员工作信息
        /// </summary>
        /// <param name="Info"></param>
        /// <param name="ID"></param>
        /// <returns></returns>
        public int AddCareerInfo(JuSNS.Model.UserCareerInfo Info, int ID)
        {
            return dal.AddCareerInfo(Info, ID);
        }

        /// <summary>
        /// 留言
        /// </summary>
        /// <param name="myid">留言者编号</param>
        /// <param name="userId">接收者编号</param>
        /// <param name="content">留言内容</param>
        /// <param name="IP">留言IP</param>
        /// <returns></returns>
        public int LeaveWords(int myid, int userId, string content, string IP)
        {
            return dal.LeaveWords(myid, userId, content, IP);
        }
         /// <summary>
        /// 检查用户是否具有某种权限
        /// </summary>
        /// <param name="privacy">权限类型</param>
        /// <param name="guest">等待验证的是否有权限的用户ID</param>
        /// <param name="host">主体者的ID</param>
        /// <returns></returns>
        public bool CheckPar(int privacy, int guest, int host)
        {
            return dal.CheckPar(privacy,guest,host);
        }

        /// <summary>
        /// 添加、更新访问信息
        /// </summary>
        /// <param name="MasterID">被访问者编号</param>
        /// <param name="VisitorID">访问者编号</param>
        /// <param name="LastVisitTime">访问时间</param>
        /// <returns></returns>
        public int InserVisit(int MasterID, int VisitorID)
        {
            return dal.InserVisit(MasterID,VisitorID);
        }

        /// <summary>
        /// 判断是否是同一个网络
        /// </summary>
        /// <param name="myId"></param>
        /// <param name="Friend"></param>
        /// <returns>true :是的  false：不是</returns>
        public bool CheckSameNet(int myId, int Friend)
        {
            return dal.CheckSameNet(myId, Friend);
        }

        /// <summary>
        /// 添加修改行业
        /// </summary>
        /// <param name="VocationName">行业名称</param>
        /// <param name="flag">标识 0：添加，1：修改</param>
        /// <returns></returns>
        public int UpdateAddVocation(int ID, string VocationName,int flag)
        {
            return dal.UpdateAddVocation(ID,VocationName,flag);
        }

        /// <summary>
        /// 锁定、解锁、删除行业信息
        /// </summary>
        /// <param name="ID">行业编号</param>
        /// <param name="value"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public int LockDelVocation(int ID, int value, int flag)
        {
            return dal.LockDelVocation(ID, value, flag);
        }

        /// <summary>
        /// 读取用户在同一时间同一操作类型的日志
        /// </summary>
        /// <param name="type"></param>
        /// <param name="userID"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public DataTable getPhoto(int type, int userID, DateTime time)
        {
            return dal.getPhoto(type,userID,time);
        }
        /// <summary>
        /// 删除添加的相片日志
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public int DelUserInfo(int ID, string time, int type, int userid)
        {
            return dal.DelUserInfo(ID,time,type,userid);
        }

        /// <summary>
        /// 得到空间模板列表
        /// </summary>
        public DataTable GetSpaceTemplateList(int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SqlConditionInfo[] SqlCondition)
        {
            return dal.GetSpaceTemplateList(PageIndex, PageSize, out RecordCount, out PageCount, SqlCondition);
        }

        /// <summary>
        /// 得到空间模板列表(后台)
        /// </summary>
        public DataTable GetSpaceTemplateList1(int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SqlConditionInfo[] SqlCondition)
        {
            return dal.GetSpaceTemplateList1(PageIndex, PageSize, out RecordCount, out PageCount, SqlCondition);
        }

        public IDataReader GetSpaceTemplate(int TID)
        {
            return dal.GetSpaceTemplate(TID);
        }

        public void UpdateSpaceTemplateLockStatc(int ID, int num)
        {
            dal.UpdateSpaceTemplateLockStatc(ID, num);
        }

        /// <summary>
        /// 更新会员被查看次数
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="times"></param>
        /// <returns></returns>
        public int InsertClick(int UserID, int times)
        {
            return dal.InsertClick(UserID,times);
        }

        /// <summary>
        /// 得到空间某条模板记录集
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public IDataReader getSpaceTemplateInfo(int ID)
        {
            return dal.getSpaceTemplateInfo(ID);
        }

        public void USpaceTemplate(int ID, string TName, string TPath, string TPicture, DateTime CreatTime, int IsLock, int IPoint, int GPoint, int isBG, int UserID, int UserNumber)
        {
            dal.USpaceTemplate(ID, TName, TPath, TPicture, CreatTime, IsLock, IPoint, GPoint, isBG, UserID, UserNumber);
        }

        /// <summary>
        /// 是否是好友
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="uID"></param>
        /// <returns></returns>
        public bool GetIsFriend(int UserID, int uID)
        {
            return dal.GetIsFriend(UserID, uID);
        }
    }
}
