Ejemplo n.º 1
0
        public static Readme Load(Int32 readmeId, bool useCache)
        {
            if (readmeId == 0)
            {
                return(null);
            }
            Readme readme = null;
            string key    = "Readme_" + readmeId.ToString();

            if (useCache)
            {
                readme = ContextCache.GetObject(key) as Readme;
                if (readme != null)
                {
                    return(readme);
                }
            }
            readme = new Readme();
            if (readme.Load(readmeId))
            {
                if (useCache)
                {
                    ContextCache.SetObject(key, readme);
                }
                return(readme);
            }
            return(null);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Loads the given Readme object from the given database data reader.
 /// </summary>
 /// <param name="readme">The Readme object to load.</param>
 /// <param name="dr">The database data reader to read data from.</param>
 public static void LoadDataReader(Readme readme, IDataReader dr)
 {
     //SET FIELDS FROM ROW DATA
     readme.ReadmeId    = dr.GetInt32(0);
     readme.StoreId     = dr.GetInt32(1);
     readme.DisplayName = dr.GetString(2);
     readme.ReadmeText  = dr.GetString(3);
     readme.IsHTML      = dr.GetBoolean(4);
     readme.IsDirty     = false;
 }
Ejemplo n.º 3
0
        public static bool Delete(Int32 readmeId)
        {
            Readme readme = new Readme();

            if (readme.Load(readmeId))
            {
                return(readme.Delete());
            }
            return(false);
        }
Ejemplo n.º 4
0
        public static ReadmeCollection 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(" " + Readme.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_Readmes");
            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
            ReadmeCollection results = new ReadmeCollection();
            int thisIndex            = 0;
            int rowCount             = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        Readme readme = new Readme();
                        Readme.LoadDataReader(readme, dr);
                        results.Add(readme);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
Ejemplo n.º 5
0
 public static SaveResult Insert(Readme readme)
 {
     return(readme.Save());
 }
Ejemplo n.º 6
0
 public static SaveResult Update(Readme readme)
 {
     return(readme.Save());
 }
Ejemplo n.º 7
0
 public static bool Delete(Readme readme)
 {
     return(readme.Delete());
 }