/// <summary> /// /// </summary> /// <returns></returns> public static List<newsviewslisting> GetAllNewsViews() { //DB Connection goes here List<newsviewslisting> _article = new List<newsviewslisting>(); // Create the Database object, using the default database service. The // default database service is determined through configuration. Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "GetAllNewsAndViews"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); // Retrieve products from the specified category. //db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, Category); // DataSet that will hold the returned results DataSet commentaryDataSet = null; commentaryDataSet = db.ExecuteDataSet(dbCommand); // Note: connection was closed by ExecuteDataSet method call foreach (DataRow dr in commentaryDataSet.Tables[0].Rows) { newsviewslisting _newsviewsListing = new newsviewslisting(); _newsviewsListing.ArticleId = Int32.Parse(dr["NewsId"].ToString()); _newsviewsListing.ArticleTitle = dr["NewsTitle"].ToString(); _newsviewsListing.ArticleDesc = dr["NewsDescription"].ToString(); _newsviewsListing.ArticleDate = DateTime.Parse(dr["Newsdatetime"].ToString()); _newsviewsListing.Ticker = dr["Ticker"].ToString(); _article.Add(_newsviewsListing); } return _article; }
/// <summary> /// /// </summary> public static newsviewslisting GetNewsViewsByArticle(int _newsId) { //DB Connection goes here newsviewslisting _newsViewsListing = new newsviewslisting(); // Create the Database object, using the default database service. The // default database service is determined through configuration. Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "GetNewsAndViewsByArticle"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); // Retrieve products from the specified category. db.AddInParameter(dbCommand, "NewsId", DbType.Int32, _newsId); // DataSet that will hold the returned results DataSet commentaryDataSet = null; commentaryDataSet = db.ExecuteDataSet(dbCommand); // Note: connection was closed by ExecuteDataSet method call foreach (DataRow dr in commentaryDataSet.Tables[0].Rows) { _newsViewsListing.ArticleTitle = dr["NewsTitle"].ToString(); _newsViewsListing.ArticleDesc = dr["NewsDescription"].ToString(); _newsViewsListing.IsActive = Boolean.Parse(dr["IsActive"].ToString()); _newsViewsListing.IsPaid = Boolean.Parse(dr["IsPaid"].ToString()); _newsViewsListing.Ticker = dr["Ticker"].ToString(); } return _newsViewsListing; }