public static PersonalizationPath Load(Int32 personalizationPathId, bool useCache) { if (personalizationPathId == 0) { return(null); } PersonalizationPath personalizationPath = null; string key = "PersonalizationPath_" + personalizationPathId.ToString(); if (useCache) { personalizationPath = ContextCache.GetObject(key) as PersonalizationPath; if (personalizationPath != null) { return(personalizationPath); } } personalizationPath = new PersonalizationPath(); if (personalizationPath.Load(personalizationPathId)) { if (useCache) { ContextCache.SetObject(key, personalizationPath); } return(personalizationPath); } return(null); }
/// <summary> /// Loads the given PersonalizationPath object from the given database data reader. /// </summary> /// <param name="personalizationPath">The PersonalizationPath object to load.</param> /// <param name="dr">The database data reader to read data from.</param> public static void LoadDataReader(PersonalizationPath personalizationPath, IDataReader dr) { //SET FIELDS FROM ROW DATA personalizationPath.PersonalizationPathId = dr.GetInt32(0); personalizationPath.StoreId = dr.GetInt32(1); personalizationPath.Path = dr.GetString(2); personalizationPath.IsDirty = false; }
public static bool Delete(Int32 personalizationPathId) { PersonalizationPath personalizationPath = new PersonalizationPath(); if (personalizationPath.Load(personalizationPathId)) { return(personalizationPath.Delete()); } return(false); }
public static PersonalizationPathCollection LoadForUser(Int32 userId, int maximumRows, int startRowIndex, string sortExpression) { //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + PersonalizationPath.GetColumnNames("ac_PersonalizationPaths")); selectQuery.Append(" FROM ac_PersonalizationPaths, ac_UserPersonalization"); selectQuery.Append(" WHERE ac_PersonalizationPaths.PersonalizationPathId = ac_UserPersonalization.PersonalizationPathId"); selectQuery.Append(" AND ac_UserPersonalization.UserId = @userId"); selectQuery.Append(" AND StoreId = @storeId"); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@userId", System.Data.DbType.Int32, userId); database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, Token.Instance.StoreId); //EXECUTE THE COMMAND PersonalizationPathCollection results = new PersonalizationPathCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { PersonalizationPath personalizationPath = new PersonalizationPath(); PersonalizationPath.LoadDataReader(personalizationPath, dr); results.Add(personalizationPath); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
public static PersonalizationPathCollection LoadForCriteria(string sqlCriteria, int maximumRows, int startRowIndex, string sortExpression) { //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + PersonalizationPath.GetColumnNames(string.Empty)); selectQuery.Append(" FROM ac_PersonalizationPaths"); string whereClause = string.IsNullOrEmpty(sqlCriteria) ? string.Empty : " WHERE " + sqlCriteria; selectQuery.Append(whereClause); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); //EXECUTE THE COMMAND PersonalizationPathCollection results = new PersonalizationPathCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { PersonalizationPath personalizationPath = new PersonalizationPath(); PersonalizationPath.LoadDataReader(personalizationPath, dr); results.Add(personalizationPath); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
/// <summary> /// Initializes the personalization object /// </summary> /// <param name="path">The path that the personalization applies to</param> public SharedPersonalization(PersonalizationPath path) : this(path.PersonalizationPathId) { this._PersonalizationPath = path; }
/// <summary> /// Initializes the personalization object /// </summary> /// <param name="path">The path that the personalization applies to</param> /// <param name="user">The user that the personalization applies to</param> public UserPersonalization(PersonalizationPath path, User user) : this(path.PersonalizationPathId, user.UserId) { this._PersonalizationPath = path; this._User = user; }
public static SaveResult Insert(PersonalizationPath personalizationPath) { return(personalizationPath.Save()); }
public static SaveResult Update(PersonalizationPath personalizationPath) { return(personalizationPath.Save()); }
public static bool Delete(PersonalizationPath personalizationPath) { return(personalizationPath.Delete()); }