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); } }
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); } }
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()); } }
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); } }