using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using JuSNS.Profile;
using JuSNS.Factory;
using JuSNS.Model;
using JuSNS.Config;

namespace JuSNS.SQLServer
{
    /// <summary>
    /// 不感兴趣投票类
    /// </summary>
    public class DisVote : DbBase, IDisVote
    {
        /// <summary>
        /// 添加不感兴趣投票
        /// </summary>
        /// <param name="Info">不感兴趣投票实体类</param>
        /// <returns>添加成功返回1</returns>
        public int Add(DisVoteInfo Info)
        {
            SqlParameter[] param = getParameters(Info);
            string Sql = "Insert Into [NT_DisVote]([VoteID],[UserID]) Values(@VoteID,@UserID)";
            return Convert.ToInt32(DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param));
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="Info">不感兴趣投票实体类</param>
        /// <returns>返回SQL参数</returns>
        private SqlParameter[] getParameters(DisVoteInfo Info)
        {
            SqlParameter[] param = new SqlParameter[3];

            param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
            param[0].Value = Info.ID;
            param[1] = new SqlParameter("@VoteID", SqlDbType.Int, 4);
            param[1].Value = Info.VoteID;
            param[2] = new SqlParameter("@UserID", SqlDbType.Int, 4);
            param[2].Value = Info.UserID;

            return param;
        }
    }
}
