public static ChatMessage GetChatMessage(LoginUser loginUser, int chatMessageID) { ChatMessages chatMessages = new ChatMessages(loginUser); chatMessages.LoadByChatMessageID(chatMessageID); if (chatMessages.IsEmpty) { return(null); } else { return(chatMessages[0]); } }
public static int GetLastMessageID(LoginUser loginUser) { ChatMessages messages = new ChatMessages(loginUser); using (SqlCommand command = new SqlCommand()) { command.CommandText = @"SELECT MAX(ChatMessageID) FROM ChatMessages"; command.CommandType = CommandType.Text; object o = messages.ExecuteScalar(command, "ChatParticipants"); if (o == null || o == DBNull.Value) { return(-1); } return((int)o); } }
public static void JoinChat(LoginUser loginUser, int id, ChatParticipantType type, int chatID, string ipAddress) { ChatMessages messages = new ChatMessages(loginUser); ChatParticipant part = (new ChatParticipants(loginUser)).AddNewChatParticipant(); part.ChatID = chatID; part.DateJoined = DateTime.UtcNow; part.ParticipantID = id; part.ParticipantType = type; part.IPAddress = ipAddress; part.LastTyped = DateTime.UtcNow.AddYears(-10); part.LastMessageID = messages.GetLastMessageID(chatID); part.Collection.Save(); part = ChatParticipants.GetChatParticipant(loginUser, id, type, chatID); if (part == null) { return; } AddNotification(loginUser, chatID, id, type, string.Format("{0} {1} has joined the chat.", part.FirstName, part.LastName)); }
public ChatMessage(DataRow row, ChatMessages chatMessages) : base(row, chatMessages) { _chatMessages = chatMessages; }