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

namespace JuSNS.Home
{
    public class Mood
    {
        JuSNS.Factory.IMood dal;
        public Mood()
        {
            dal = DataAccess.CreateMood();
        }
        /// <summary>
        /// 保存心情日记
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="Content">内容</param>
        /// <param name="MType">类型</param>
        /// <returns></returns>
        public int SaveMini(int userId, string content, string MType)
        {
            return dal.SaveMini(userId, content, MType);
        }
        /// <summary>
        /// 删除心情日记
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public int DeleteMini(int userId, int miniId)
        {
            return dal.DeleteMini(userId, miniId, false);
        }
        /// <summary>
        /// 获取MiniBlog实例
        /// </summary>
        /// <param name="MiniID">MiniBlogID</param>
        /// <returns></returns>
        public MiniBlogInfo GetMiniInfo(int MiniID)
        {
            return dal.GetMiniInfo(MiniID);
        }
        /// <summary>
        /// 检查是否有查看迷你日志的权限
        /// </summary>
        /// <param name="hostId"></param>
        /// <param name="guestId"></param>
        /// <returns></returns>
        public bool CheckAuthority(int hostId, int guestId)
        {
            if (hostId == guestId)
                return true;
            else
                return dal.CheckAuthority(hostId, guestId);
        }
        /// <summary>
        /// 获取用户的最后发布的心情日记
        /// </summary>
        /// <param name="vistor"></param>
        /// <param name="owner"></param>
        /// <returns></returns>
        public MiniBlogInfo GetLastInfo(int vistor, int owner)
        {
            return dal.GetLastInfo(vistor, owner);
        }

        /// <summary>
        /// 得到心情日记的评论
        /// </summary>
        /// <param name="Mid">心情日记的ID</param>
        /// <returns></returns>
        public IDataReader GetMiniComment(int mid)
        {
            return dal.GetMiniComment(mid);
        }

        /// <summary>
        /// 得到迷你博客的评论数量
        /// </summary>
        /// <param name="mid">迷你博客ID</param>
        /// <returns></returns>
        public int GetMiniCount(int mid)
        {
            return dal.GetMiniCount(mid);
        }

        /// <summary>
        /// 保存心情日记评论
        /// </summary>
        /// <param name="mid">被评论的ID</param>
        /// <param name="Content">内容</param>
        /// <param name="UserID">用户</param>
        /// <param name="CommentID">父ID</param>
        public void SaveMiniComment(int mid, string Content, int UserID, int CommentID)
        {
            dal.SaveMiniComment(mid, Content, UserID, CommentID);
        }

        /// <summary>
        /// 删除心情日记评论
        /// </summary>
        /// <param name="bid"></param>
        public void DelMiniComent(int bid)
        {
            dal.DelMiniComent(bid);
        }
    }
}
