/// <summary> /// Gets all posts /// </summary> /// <param name="ForumTopicID">The forum topic identifier</param> /// <param name="UserID">The user identifier</param> /// <param name="Keywords">Keywords</param> /// <param name="AscSort">Sort order</param> /// <param name="PageSize">Page size</param> /// <param name="PageIndex">Page index</param> /// <param name="TotalRecords">Total records</param> /// <returns>Posts</returns> public override DBForumPostCollection GetAllPosts(int ForumTopicID, int UserID, string Keywords, bool AscSort, int PageSize, int PageIndex, out int TotalRecords) { TotalRecords = 0; DBForumPostCollection forumPostCollection = new DBForumPostCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_Forums_PostLoadAll"); db.AddInParameter(dbCommand, "TopicID", DbType.Int32, ForumTopicID); db.AddInParameter(dbCommand, "UserID", DbType.Int32, UserID); db.AddInParameter(dbCommand, "Keywords", DbType.String, Keywords); db.AddInParameter(dbCommand, "AscSort", DbType.Boolean, AscSort); db.AddInParameter(dbCommand, "PageSize", DbType.Int32, PageSize); db.AddInParameter(dbCommand, "PageIndex", DbType.Int32, PageIndex); db.AddOutParameter(dbCommand, "TotalRecords", DbType.Int32, 0); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBForumPost forumPost = GetForumPostFromReader(dataReader); forumPostCollection.Add(forumPost); } } TotalRecords = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TotalRecords")); return forumPostCollection; }
private static ForumPostCollection DBMapping(DBForumPostCollection dbCollection) { if (dbCollection == null) return null; ForumPostCollection collection = new ForumPostCollection(); foreach (DBForumPost dbItem in dbCollection) { ForumPost item = DBMapping(dbItem); collection.Add(item); } return collection; }