예제 #1
0
        /// <summary>
        /// Gets private messages
        /// </summary>
        /// <param name="FromUserID">The user identifier who sent the message</param>
        /// <param name="ToUserID">The user identifier who should receive the message</param>
        /// <param name="IsRead">A value indicating whether loaded messages are read. false - to load not read messages only, 1 to load read messages only, null to load all messages</param>
        /// <param name="IsDeletedByAuthor">A value indicating whether loaded messages are deleted by author. false - messages are not deleted by author, null to load all messages</param>
        /// <param name="IsDeletedByRecipient">A value indicating whether loaded messages are deleted by recipient. false - messages are not deleted by recipient, null to load all messages</param>
        /// <param name="Keywords">Keywords</param>
        /// <param name="PageSize">Page size</param>
        /// <param name="PageIndex">Page index</param>
        /// <param name="TotalRecords">Total records</param>
        /// <returns>Private messages</returns>
        public override DBPrivateMessageCollection GetAllPrivateMessages(int FromUserID, int ToUserID,
            bool? IsRead, bool? IsDeletedByAuthor, bool? IsDeletedByRecipient, 
            string Keywords, int PageSize, int PageIndex, out int TotalRecords)
        {
            TotalRecords = 0;
            DBPrivateMessageCollection privateMessageCollection = new DBPrivateMessageCollection();
            Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_Forums_PrivateMessageLoadAll");
            db.AddInParameter(dbCommand, "FromUserID", DbType.Int32, FromUserID);
            db.AddInParameter(dbCommand, "ToUserID", DbType.Int32, ToUserID);
            if (IsRead.HasValue)
                db.AddInParameter(dbCommand, "IsRead", DbType.Boolean, IsRead.Value);
            else
                db.AddInParameter(dbCommand, "IsRead", DbType.Boolean, null);
            if (IsDeletedByAuthor.HasValue)
                db.AddInParameter(dbCommand, "IsDeletedByAuthor", DbType.Boolean, IsDeletedByAuthor.Value);
            else
                db.AddInParameter(dbCommand, "IsDeletedByAuthor", DbType.Boolean, null);
            if (IsDeletedByRecipient.HasValue)
                db.AddInParameter(dbCommand, "IsDeletedByRecipient", DbType.Boolean, IsDeletedByRecipient.Value);
            else
                db.AddInParameter(dbCommand, "IsDeletedByRecipient", DbType.Boolean, null);
            db.AddInParameter(dbCommand, "Keywords", DbType.String, Keywords);
            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())
                {
                    DBPrivateMessage privateMessage = GetPrivateMessageFromReader(dataReader);
                    privateMessageCollection.Add(privateMessage);
                }
            }
            TotalRecords = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TotalRecords"));

            return privateMessageCollection;
        }
예제 #2
0
        private static PrivateMessageCollection DBMapping(DBPrivateMessageCollection dbCollection)
        {
            if (dbCollection == null)
                return null;

            PrivateMessageCollection collection = new PrivateMessageCollection();
            foreach (DBPrivateMessage dbItem in dbCollection)
            {
                PrivateMessage item = DBMapping(dbItem);
                collection.Add(item);
            }

            return collection;
        }