예제 #1
0
        private static IList <OffLineMessage> LoadListFromReader(IDataReader reader)
        {
            IList <OffLineMessage> offLineMessageList = new List <OffLineMessage>();

            try
            {
                while (reader.Read())
                {
                    OffLineMessage offLineMessage = new OffLineMessage();
                    offLineMessage.Id          = Convert.ToInt32(reader["Id"]);
                    offLineMessage.UserID      = reader["UserID"].ToString();
                    offLineMessage.UserName    = reader["UserName"].ToString();
                    offLineMessage.DestUserID  = reader["DestUserID"].ToString();
                    offLineMessage.DestUerName = reader["DestUerName"].ToString();
                    offLineMessage.ChatContent = reader["ChatContent"].ToString();
                    offLineMessage.SendTime    = Convert.ToDateTime(reader["SendTime"]);
                    offLineMessageList.Add(offLineMessage);
                }
            }
            finally
            {
                reader.Close();
            }

            return(offLineMessageList);
        }
예제 #2
0
 /// <summary>
 /// Saves this instance of OffLineMessage. Returns true on success.
 /// </summary>
 /// <returns>bool</returns>
 public static bool Save(OffLineMessage offLineMessage)
 {
     if (offLineMessage.Id > 0)
     {
         return(Update(offLineMessage));
     }
     else
     {
         return(Create(offLineMessage));
     }
 }
예제 #3
0
 /// <summary>
 /// Updates this instance of OffLineMessage. Returns true on success.
 /// </summary>
 /// <returns>bool</returns>
 private static bool Update(OffLineMessage offLineMessage)
 {
     return(DBOffLineMessage.Update(
                offLineMessage.Id,
                offLineMessage.UserID,
                offLineMessage.UserName,
                offLineMessage.DestUserID,
                offLineMessage.DestUerName,
                offLineMessage.ChatContent,
                offLineMessage.SendTime));
 }
예제 #4
0
        /// <summary>
        /// Persists a new instance of OffLineMessage. Returns true on success.
        /// </summary>
        /// <returns></returns>
        private static bool Create(OffLineMessage offLineMessage)
        {
            int newID = 0;

            newID = DBOffLineMessage.Create(
                offLineMessage.UserID,
                offLineMessage.UserName,
                offLineMessage.DestUserID,
                offLineMessage.DestUerName,
                offLineMessage.ChatContent,
                offLineMessage.SendTime);

            offLineMessage.Id = newID;

            return(newID > 0);
        }
예제 #5
0
        private static OffLineMessage PopulateFromReader(IDataReader reader)
        {
            OffLineMessage offLineMessage = new OffLineMessage();

            if (reader.Read())
            {
                offLineMessage.Id          = Convert.ToInt32(reader["Id"]);
                offLineMessage.UserID      = reader["UserID"].ToString();
                offLineMessage.UserName    = reader["UserName"].ToString();
                offLineMessage.DestUserID  = reader["DestUserID"].ToString();
                offLineMessage.DestUerName = reader["DestUerName"].ToString();
                offLineMessage.ChatContent = reader["ChatContent"].ToString();
                offLineMessage.SendTime    = Convert.ToDateTime(reader["SendTime"]);
            }
            return(offLineMessage);
        }