//by JuSNS v1.0系列
//官方站：www.juSNS.com，演示站:www.ju001.com，www.julala.cn
//QQ:655071(技术)，QQ:9170617（客服）
//MSN:simplt@163.com EMail:simplt@163.com
//program design by Simplt.Xie，arjun
//========================================

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

namespace JuSNS.Home
{
    /// <summary>
    /// 群组成员类
    /// </summary>
    public class GroupMember
    {
        private IGroupMember dal;
        public GroupMember()
        {
            dal = DataAccess.CreateGroupMember();
        }
        /// <summary>
        /// 加入群组
        /// </summary>
        /// <param name="Info">群组成员实体类</param>
        /// <returns>加入成功返回1</returns>
        public int Join(GroupMemberInfo Info)
        {
            return dal.Join(Info);
        }

        /// <summary>
        /// 退出一个群
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <param name="GroupID">群编号</param>
        /// <returns></returns>
        public int Out(int UserID, int GroupID)
        {
            return dal.Out(UserID, GroupID);
        }

        /// <summary>
        /// 设置群成员为管理员
        /// </summary>
        /// <param name="GroupUserID">群成员编号</param>
        /// <param name="GroupID">组编号</param>
        /// <param name="UserID">群主编号</param>
        /// <returns>设置成功返回1</returns>
        public int SetAdmin(int GroupUserID, int GroupID, int UserID)
        {
            return dal.SetAdmin(GroupUserID, GroupID, UserID);
        }

        /// <summary>
        /// 删除群管理员
        /// </summary>
        /// <param name="GroupUserID">群成员编号</param>
        /// <param name="GroupID">组编号</param>
        /// <param name="UserID">群主编号</param>
        /// <returns>设置成功返回1</returns>
        public int DelAdmin(int GroupUserID, int GroupID, int UserID)
        {
            return dal.DelAdmin(GroupUserID, GroupID, UserID);
        }

        /// <summary>
        /// 管理员辞职
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <param name="GroupID">群组编号</param>
        /// <returns>辞职成功返回1</returns>
        public int QuitGroup(int UserID, int GroupID)
        {
            return dal.QuitGroup(UserID, GroupID);
        }

        /// <summary>
        /// 取得群组各等级类型的群员列表
        /// </summary>
        /// <param name="Grade">等级</param>
        /// <param name="GroupID">组编号</param>
        /// <returns></returns>
        public DataTable GroupMemberGradeList(int Grade, int GroupID)
        {
            return dal.GroupMemberGradeList(Grade, GroupID);
        }

        /// <summary>
        /// 取得最新六位成员
        /// </summary>
        /// <param name="GroupID">群组编号</param>
        /// <returns>返回数据表</returns>
        public DataTable Top6GroupMemberList(int GroupID)
        {
            return dal.Top6GroupMemberList(GroupID);
        }

        /// <summary>
        /// 检查会员是不是此组的成员
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <param name="GroupID">群组编号</param>
        /// <returns>如果是返回true，否则返回false</returns>
        public bool IsGroupMember(int UserID, int GroupID)
        {
            return dal.IsGroupMember(UserID, GroupID);
        }

        /// <summary>
        /// 检查会员是不是此组的管理员
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <param name="GroupID">群组编号</param>
        /// <returns>如果是返回true，否则返回false</returns>
        public bool IsGroupAdmin(int UserID, int GroupID)
        {
            return dal.IsGroupAdmin(UserID, GroupID);
        }

        /// <summary>
        /// 取得群组是否有邀请
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <returns>返回数据表</returns>
        public DataTable getGroupRequest(int UserID)
        {
            return dal.getGroupRequest(UserID);
        }

        /// <summary>
        /// 取得群组成员信息
        /// </summary>
        /// <param name="ID">记录编号</param>
        /// <returns></returns>
        public GroupMemberInfo Info(int ID)
        {
            return dal.Info(ID);
        }
    }
}
