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); }
/// <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)); } }
/// <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)); }
/// <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); }
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); }