Exemplo n.º 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);
        }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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));
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }