Пример #1
0
        public bool UpdateHostConfig(HostConfigModel model)
        {
            string sql = @" update SJHostConfig set Value=@Value where Id=@Id;";

            using (var connection = SqlDb.UpdateConnection)
            {
                return(connection.Execute(sql, model) > 0);
            }
        }
Пример #2
0
        public bool InsertHostConfig(HostConfigModel model)
        {
            string sql = @" insert into SJHostConfig(TypeId,TypeDesciption,Host,Value,UserId) values(@TypeId,@TypeDesciption,@Host,@HostValue,@UserId)";

            using (var connection = SqlDb.UpdateConnection)
            {
                return(connection.Execute(sql, model) > 0);
            }
        }
Пример #3
0
        public HostConfigModel GetHostConfig(HostConfigModel model)
        {
            string sql = @"select Id,TypeId,TypeDesciption,Host,Value HostValue,UserId from SJHostConfig where TypeId=@TypeId and Host=@Host ";

            using (var connection = SqlDb.UpdateConnection)
            {
                return(connection.Query <HostConfigModel>(sql, model).FirstOrDefault());
            }
        }
Пример #4
0
        public bool SaveHostConfig(HostConfigModel model)
        {
            string sql = @" 
                            if(exists(select 1 from SJHostConfig where Host=@Host and UserId=@UserId and TypeId=@TypeId))
                                 update SJHostConfig set Value=@HostValue where Id=@Id;
                            else
                                insert into SJHostConfig(TypeId,TypeDesciption,Host,Value,UserId) values(@TypeId,@TypeDesciption,@Host,@HostValue,@UserId)";

            using (var connection = SqlDb.UpdateConnection)
            {
                return(connection.Execute(sql, model) > 0);
            }
        }