using System;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using JuSNS.Model;

namespace JuSNS.Factory
{
    /// <summary>
    /// 投票类接口
    /// </summary>
    public interface IVote
    {
        /// <summary>
        /// 添加投票
        /// </summary>
        /// <param name="Info">投票实体类</param>
        /// <returns>添加成功返回投票编号</returns>
        int Add(VoteInfo Info);

        /// <summary>
        /// 删除投票
        /// </summary>
        /// <param name="VoteID">投票编号</param>
        /// <param name="UserID">用户编号</param>
        /// <returns>删除成功返回1</returns>
        int Del(int VoteID, int UserID);

        /// <summary>
        /// 添加参加人数
        /// </summary>
        /// <param name="ID">投票编号</param>
        /// <returns>添加成功返回1</returns>
        int AddJCnt(int ID);

        /// <summary>
        /// 用户添加的投票数
        /// </summary>
        /// <param name="UserID">投票编号</param>
        /// <returns>返回记录数</returns>
        int MyAddCnt(int UserID);

        /// <summary>
        /// 相册信息
        /// </summary>
        /// <param name="ID">投票编号</param>
        /// <returns>返回投票实体类</returns>
        VoteInfo Info(int ID);

        /// <summary>
        /// 好友最近发起的投票列表
        /// </summary>
        /// <param name="Num">条数</param>
        /// <param name="UserID">会员编号</param>
        /// <returns>返回列表</returns>
        DataTable FriendNewVoteList(int Num, int UserID);

        /// <summary>
        /// 好友最近参加的投票列表
        /// </summary>
        /// <param name="Num">条数</param>
        /// <param name="UserID">会员编号</param>
        /// <returns>返回列表</returns>
        DataTable FriendNewJoinVoteList(int Num, int UserID);

        /// <summary>
        /// 最近的热门投票列表
        /// </summary>
        /// <param name="Num">条数</param>
        /// <returns>返回列表</returns>
        DataTable HotVote(int Num);

        /// <summary>
        /// 我发起的投票列表
        /// </summary>
        /// <param name="Num">条数</param>
        /// <param name="UserID">会员编号</param>
        /// <returns>返回列表</returns>
        DataTable MyAddVote(int Num, int UserID);

        /// <summary>
        /// 我发起的投票列表(排除当前的投票编号)
        /// </summary>
        /// <param name="Num">条数</param>
        /// <param name="UserID">会员编号</param>
        /// <param name="VoteID">会员编号</param>
        /// <returns>返回列表</returns>
        DataTable MyAddVote(int Num, int UserID, int VoteID);

        /// <summary>
        /// 我参与的投票列表
        /// </summary>
        /// <param name="Num">条数</param>
        /// <param name="UserID">会员编号</param>
        /// <returns>返回列表</returns>
        DataTable MyJoinVote(int Num, int UserID);

        /// <summary>
        /// 取得朋友投票选项
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <param name="VoteID">投票编号</param>
        /// <returns>返回数据表</returns>
        DataTable FriendVote(int UserID, int VoteID);

        /// <summary>
        /// 其它人投票
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <param name="VoteID">投票编号</param>
        /// <returns>返回数据表</returns>
        DataTable OtherVote(int UserID, int VoteID);
    }

    public sealed partial class DataAccess
    {
        public static IVote CreateVote()
        {
            string className = path + ".Vote";
            return (IVote)Assembly.Load(path).CreateInstance(className);
        }
    }
}