Exemplo n.º 1
0
        /// <summary>
        /// Gets news item collection
        /// </summary>
        /// <param name="LanguageID">Language identifier. 0 if you want to get all news</param>
        /// <param name="NewsCount">News item count. 0 if you want to get all news</param>
        /// <returns>News item collection</returns>
        public static NewsCollection GetNews(int LanguageID, int NewsCount)
        {
            bool             showHidden   = NopContext.Current.IsAdmin;
            DBNewsCollection dbCollection = DBProviderManager <DBNewsProvider> .Provider.GetNews(LanguageID, NewsCount, showHidden);

            NewsCollection collection = DBMapping(dbCollection);

            return(collection);
        }
Exemplo n.º 2
0
        private static NewsCollection DBMapping(DBNewsCollection dbCollection)
        {
            if (dbCollection == null)
            {
                return(null);
            }

            NewsCollection collection = new NewsCollection();

            foreach (DBNews dbItem in dbCollection)
            {
                News item = DBMapping(dbItem);
                collection.Add(item);
            }

            return(collection);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets news item collection
        /// </summary>
        /// <param name="LanguageID">Language identifier. 0 if you want to get all news</param>
        /// <param name="NewsCount">News item count. 0 if you want to get all news</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>News item collection</returns>
        public override DBNewsCollection GetNews(int LanguageID, int NewsCount, bool showHidden)
        {
            DBNewsCollection newsCollection = new DBNewsCollection();
            Database         db             = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand        dbCommand      = db.GetStoredProcCommand("Nop_NewsLoadAll");

            db.AddInParameter(dbCommand, "LanguageID", DbType.Int32, LanguageID);
            db.AddInParameter(dbCommand, "NewsCount", DbType.Int32, NewsCount);
            db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBNews news = GetNewsFromReader(dataReader);
                    newsCollection.Add(news);
                }
            }

            return(newsCollection);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets news item collection
        /// </summary>
        /// <param name="languageId">Language identifier. 0 if you want to get all news</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <param name="pageSize">Page size</param>
        /// <param name="pageIndex">Page index</param>
        /// <param name="totalRecords">Total records</param>
        /// <returns>News item collection</returns>
        public override DBNewsCollection GetAllNews(int languageId, bool showHidden, int pageIndex, int pageSize, out int totalRecords)
        {
            var       result    = new DBNewsCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_NewsLoadAll");

            db.AddInParameter(dbCommand, "LanguageID", DbType.Int32, languageId);
            db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden);
            db.AddInParameter(dbCommand, "PageIndex", DbType.Int32, pageIndex);
            db.AddInParameter(dbCommand, "PageSize", DbType.Int32, pageSize);
            db.AddOutParameter(dbCommand, "TotalRecords", DbType.Int32, 0);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    result.Add(GetNewsFromReader(dataReader));
                }
            }

            totalRecords = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TotalRecords"));

            return(result);
        }