public static WrapGroup Load(Int32 wrapGroupId, bool useCache)
        {
            if (wrapGroupId == 0)
            {
                return(null);
            }
            WrapGroup wrapGroup = null;
            string    key       = "WrapGroup_" + wrapGroupId.ToString();

            if (useCache)
            {
                wrapGroup = ContextCache.GetObject(key) as WrapGroup;
                if (wrapGroup != null)
                {
                    return(wrapGroup);
                }
            }
            wrapGroup = new WrapGroup();
            if (wrapGroup.Load(wrapGroupId))
            {
                if (useCache)
                {
                    ContextCache.SetObject(key, wrapGroup);
                }
                return(wrapGroup);
            }
            return(null);
        }
        public static bool Delete(Int32 wrapGroupId)
        {
            WrapGroup wrapGroup = new WrapGroup();

            if (wrapGroup.Load(wrapGroupId))
            {
                return(wrapGroup.Delete());
            }
            return(false);
        }
        public static WrapGroupCollection 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(" " + WrapGroup.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_WrapGroups");
            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
            WrapGroupCollection results = new WrapGroupCollection();
            int thisIndex = 0;
            int rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        WrapGroup wrapGroup = new WrapGroup();
                        WrapGroup.LoadDataReader(wrapGroup, dr);
                        results.Add(wrapGroup);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
Example #4
0
        /// <summary>
        /// Creates a copy of the given wrap group
        /// </summary>
        /// <param name="wrapGroupId">Id of the wrap group to create copy of</param>
        /// <param name="deepCopy">If true all wrap styles are also copied</param>
        /// <returns></returns>
        public static WrapGroup Copy(int wrapGroupId, bool deepCopy)
        {
            WrapGroup copy = WrapGroupDataSource.Load(wrapGroupId);

            if (copy != null)
            {
                if (deepCopy)
                {
                    //LOAD THE CHILD COLLECTIONS AND RESET
                    foreach (WrapStyle style in copy.WrapStyles)
                    {
                        style.WrapStyleId = 0;
                        style.WrapGroupId = 0;
                    }
                }
                copy.WrapGroupId = 0;
                return(copy);
            }
            return(null);
        }
 public static SaveResult Insert(WrapGroup wrapGroup)
 {
     return(wrapGroup.Save());
 }
 public static SaveResult Update(WrapGroup wrapGroup)
 {
     return(wrapGroup.Save());
 }
 public static bool Delete(WrapGroup wrapGroup)
 {
     return(wrapGroup.Delete());
 }