예제 #1
0
        public static StoreSetting Load(Int32 storeSettingId, bool useCache)
        {
            if (storeSettingId == 0)
            {
                return(null);
            }
            StoreSetting storeSetting = null;
            string       key          = "StoreSetting_" + storeSettingId.ToString();

            if (useCache)
            {
                storeSetting = ContextCache.GetObject(key) as StoreSetting;
                if (storeSetting != null)
                {
                    return(storeSetting);
                }
            }
            storeSetting = new StoreSetting();
            if (storeSetting.Load(storeSettingId))
            {
                if (useCache)
                {
                    ContextCache.SetObject(key, storeSetting);
                }
                return(storeSetting);
            }
            return(null);
        }
 /// <summary>
 /// Loads the given StoreSetting object from the given database data reader.
 /// </summary>
 /// <param name="storeSetting">The StoreSetting object to load.</param>
 /// <param name="dr">The database data reader to read data from.</param>
 public static void LoadDataReader(StoreSetting storeSetting, IDataReader dr)
 {
     //SET FIELDS FROM ROW DATA
     storeSetting.StoreSettingId = dr.GetInt32(0);
     storeSetting.StoreId        = dr.GetInt32(1);
     storeSetting.FieldName      = dr.GetString(2);
     storeSetting.FieldValue     = dr.GetString(3);
     storeSetting.IsDirty        = false;
 }
예제 #3
0
        public static bool Delete(Int32 storeSettingId)
        {
            StoreSetting storeSetting = new StoreSetting();

            if (storeSetting.Load(storeSettingId))
            {
                return(storeSetting.Delete());
            }
            return(false);
        }
        /// <summary>
        /// Sets the value of a setting for given key
        /// </summary>
        /// <param name="key">The key for which to set the value</param>
        /// <param name="value">The value to set</param>
        public void SetValueByKey(string key, string value)
        {
            StoreSetting setting = (StoreSetting)settingMap[key];

            if (setting == null)
            {
                setting = new StoreSetting();
            }
            setting.FieldName  = key;
            setting.FieldValue = value;
            this.Add(setting);
        }
예제 #5
0
        public static StoreSettingCollection LoadForStore(int maximumRows, int startRowIndex, string sortExpression)
        {
            int storeId = Token.Instance.StoreId;
            //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(" " + StoreSetting.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_StoreSettings");
            selectQuery.Append(" WHERE 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, "@storeId", System.Data.DbType.Int32, storeId);
            //EXECUTE THE COMMAND
            StoreSettingCollection results = new StoreSettingCollection();
            int thisIndex = 0;
            int rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        StoreSetting storeSetting = new StoreSetting();
                        StoreSetting.LoadDataReader(storeSetting, dr);
                        results.Add(storeSetting);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
 /// <summary>
 /// Add a new store setting to this collection
 /// </summary>
 /// <param name="item">The store setting to add</param>
 public new void Add(StoreSetting item)
 {
     settingMap[item.FieldName] = item;
     base.Add(item);
 }
예제 #7
0
 public static SaveResult Insert(StoreSetting storeSetting)
 {
     return(storeSetting.Save());
 }
예제 #8
0
 public static SaveResult Update(StoreSetting storeSetting)
 {
     return(storeSetting.Save());
 }
예제 #9
0
 public static bool Delete(StoreSetting storeSetting)
 {
     return(storeSetting.Delete());
 }