using PoJun.Dapper;
using ASHermed.SinoInterface.Api.IRepository.Test;
using ASHermed.SinoInterface.Entity.Test;
using ASHermed.SinoInterface.Repository.MySql;
using ASHermed.SinoInterface.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ASHermed.SinoInterface.Api.ContractModel.App;
using ASHermed.SinoInterface.Api.IRepository;

namespace ASHermed.SinoInterface.Api.MySqlRepository
{

    public class PubMapUserTypeRepository : BaseRepositoryToASHermed_SinoInterface<Pub_Map_User_Type>, IPubMapUserTypeRepository
    {
        public int InsertPubMapUserType(Pub_Map_User_Type userType)
        {
            StringBuilder str = new StringBuilder();
            str.Append("insert into Pub_Map_User_Type ");
            str.Append(@"(PHONE_NO,USER_TYPE,AVAILABLE_COUPON) ");
            str.Append(" values ");
            str.Append(@"(@PHONE_NO,@USER_TYPE,@AVAILABLE_COUPON); ");
            str.Append("select @@identity; ");
            var parms = new Dictionary<string, object>();
            parms.Add("@PHONE_NO", userType.Phone_No);
            parms.Add("@USER_TYPE", userType.User_Type);
            parms.Add("@AVAILABLE_COUPON", userType.Available_Coupon);
            var result = Execute(str.ToString(), parms);
            return result;
        }

        public int UpdatePubMapUserType(Pub_Map_User_Type userType)
        {
            StringBuilder str = new StringBuilder();
            str.Append("update Pub_Map_User_Type set ");
            str.Append(@"PHONE_NO=@PHONE_NO,
                            USER_TYPE=@USER_TYPE,
                            AVAILABLE_COUPON=@AVAILABLE_COUPON ");
            str.Append(@" where ID=@ID");
            var parms = new Dictionary<string, object>();
            parms.Add("@PHONE_NO", userType.Phone_No);
            parms.Add("@USER_TYPE", userType.User_Type);
            parms.Add("@AVAILABLE_COUPON", userType.Available_Coupon);
            parms.Add("@ID", userType.Id);
            var result = Execute(str.ToString(), parms);
            return result;
        }





    }


}
