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

namespace JuSNS.Home
{
    /// <summary>
    /// 私信类
    /// </summary>
    public class Mail
    {
        private IMail dal;

        /// <summary>
        /// 构造函数
        /// </summary>
        public Mail()
        {
            dal = DataAccess.CreateMail();
        }

        /// <summary>
        /// 添加私信
        /// </summary>
        /// <param name="Info">私信实体类</param>
        /// <returns>添加成功返回1</returns>
        public int Add(Mailinfo Info)
        {
            return dal.Add(Info);
        }

        /// <summary>
        /// 删除私信
        /// </summary>
        /// <param name="dType">类型,0为发件箱,1为收件箱</param>
        /// <param name="LetterID">私信编号</param>
        /// <returns>删除成功返回1</returns>
        public int Del(int dType, int LetterID, int UserID)
        {
            return dal.Del(dType, LetterID, UserID);
        }

        /// <summary>
        /// 回复私信
        /// </summary>
        /// <param name="Info">私信实体类</param>
        /// <returns>回复成功返回1</returns>
        public int Reply(Mailinfo Info)
        {
            return dal.Reply(Info);
        }

        /// <summary>
        /// 更新通知状态
        /// </summary>
        /// <param name="UserID">会员编号</param>
        public void UpdateNoticeMode(int UserID)
        {
            dal.UpdateNoticeMode(UserID);
        }

        /// <summary>
        /// 设置收到的信息为已读状态
        /// </summary>
        /// <param name="LetterID">私信编号</param>
        /// <param name="UserID">用户编号</param>
        /// <returns>操作成功返回1</returns>
        public int Read(int LetterID, int UserID)
        {
            return dal.Read(LetterID, UserID);
        }

        /// <summary>
        /// 取得最新回复内容
        /// </summary>
        /// <param name="LetterID">私信编号</param>
        /// <param name="isMy">是否自已回复的最新内容</param>
        /// <param name="UserID">用户编号</param>
        /// <returns>返回最新回复内容</returns>
        public string getNewReContent(int LetterID, bool isMy, int UserID)
        {
            return dal.getNewReContent(LetterID, isMy, UserID);
        }

        /// <summary>
        /// 取得最新的回复是否被阅读
        /// </summary>
        /// <param name="LetterID">私信编号</param>
        /// <param name="UserID">用户编号</param>
        /// <returns>0为未读，1为已读</returns>
        public int getNewReCNT(int LetterID, int UserID)
        {
            return dal.getNewReCNT(LetterID, UserID);
        }

        /// <summary>
        /// 取得收信箱
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <returns>返回收信箱未读邮件记录数</returns>
        public int InBoxCount(int UserID)
        {
            return dal.InBoxCount(UserID);
        }

        /// <summary>
        /// 私信信息
        /// </summary>
        /// <param name="PhotoID">私信编号</param>
        /// <returns>返回私信实体类</returns>
        public Mailinfo Info(int ID)
        {
            return dal.Info(ID);
        }
    }
}
