using ASHermed.SinoInterface.Api.ContractModel.App;
using ASHermed.SinoInterface.Api.IRepository;
using ASHermed.SinoInterface.Repository.MySql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASHermed.SinoInterface.Api.MySqlRepository
{
    public class PubSmsLogRepository : BaseRepositoryToASHermed_SinoInterface<Pub_Sms_Log>, IPubSmsLogRepository
    {
        public int InsertPubSmsLog(Pub_Sms_Log smsLog)
        {
            StringBuilder str = new StringBuilder();
            str.Append("insert into Pub_Sms_Log (SMS_TYPE,REQUEST,RESULT,SEND_TIME,SMS_CONTENT,CREATE_TIME)  values (@SMS_TYPE,@REQUEST,@RESULT,@SEND_TIME,@SMS_CONTENT,@CREATE_TIME)");
            var parms = new Dictionary<string, object>();
            parms.Add("@SMS_TYPE", smsLog.Sms_Type);
            parms.Add("@REQUEST", smsLog.Request);
            parms.Add("@RESULT", smsLog.Result);
            parms.Add("@SEND_TIME", smsLog.Send_Time);
            parms.Add("@SMS_CONTENT", smsLog.Sms_Content);
            parms.Add("@CREATE_TIME", DateTime.Now);
            var result = Insert(str.ToString(), parms);
            return result;
        }

        public int UpdateByPrimaryKey(Pub_Sms_Log smsLog)
        {
            var parms = new Dictionary<string, object>();
            StringBuilder str = new StringBuilder();
            str.Append(@"update Pub_Sms_Log set
                            SMS_TYPE =@SMS_TYPE, 
                            REQUEST=@REQUEST,
                            RESULT=@RESULT,
                            SEND_TIME=@SEND_TIME,
                            SMS_CONTENT=@SMS_CONTENT
                            where ID=@ID
                            ");
            parms.Add("@SMS_TYPE", smsLog.Sms_Type);
            parms.Add("@REQUEST", smsLog.Request);
            parms.Add("@RESULT", smsLog.Result);
            parms.Add("@SEND_TIME", smsLog.Send_Time);
            parms.Add("@SMS_CONTENT", smsLog.Sms_Type);
            parms.Add("@ID", smsLog.Id);
            var result = Execute(str.ToString(), parms);
            return result;
        }


        public int InsertPubSmsSurvey(Pub_Sms_Survey survey)
        {
            StringBuilder str = new StringBuilder();
            str.Append("insert into Pub_Sms_Survey (PID,PHONE,NAME,APT_TIME,CONTENT,HOS_ID,PAT_MRN)  values (@PID,@PHONE,@NAME,@APT_TIME,@CONTENT,@HOS_ID,@PAT_MRN)");
            var parms = new Dictionary<string, object>();
            parms.Add("@PID", survey.Pid);
            parms.Add("@PHONE", survey.Phone);
            parms.Add("@NAME", survey.Name);
            parms.Add("@APT_TIME", survey.Apt_Time);
            parms.Add("@CONTENT", survey.Content);
            parms.Add("@HOS_ID", survey.Hos_Id);
            parms.Add("@PAT_MRN", survey.Pat_Mrn);
            var result = Insert(str.ToString(), parms);
            return result;
        }
    }
}
