private void PopulateMessageCollection() { var messageList = IMService.GetAllMessagesBetweenContacts(LoggedInUser, GetSelectedUser()); foreach (var message in messageList) { MessagesCollection.Add(message); } }
private void SendButton_Click(object sender, RoutedEventArgs e) { if (MessageContent != null && MessageContent != "" && SelectedContact != null) { var message = new Message { Sender = LoggedInUser.Username, Receiver = SelectedContact.Username, TimeSent = DateTime.Now, Content = MessageContent }; IMService.SendMessage(message); MessagesCollection.Add(message); MessageContent = ""; SelectedContact.LastMessageContent = message.Content; SelectedContact.LastMessageTime = message.TimeSent; } }
public static MessagesCollection Search(SearchFilter SearchKey) { MessagesCollection collection = new MessagesCollection(); using (var reader = SqlHelper.ExecuteReader("Messages_Search", SearchFilterManager.SqlSearchDynParam(SearchKey))) { while (reader.Read()) { Messages obj = new Messages(); obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
public static MessagesCollection GetbyUser(string CreatedUser, int CompanyID) { MessagesCollection collection = new MessagesCollection(); Messages obj; var sqlParams = new SqlParameter[] { new SqlParameter("@CreatedUser", CreatedUser), new SqlParameter("@CompanyID", CompanyID), }; using (var reader = SqlHelper.ExecuteReader("Messages_GetAll_byUser", sqlParams)) { while (reader.Read()) { obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
public static MessagesCollection GetAllItem(int CompanyID) { MessagesCollection collection = new MessagesCollection(); var sqlParams = new SqlParameter[] { new SqlParameter("@CompanyID", CompanyID), }; using (var reader = SqlHelper.ExecuteReader("Messages_GetAll", sqlParams)) { while (reader.Read()) { Messages obj = new Messages(); obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
private void CheckForNewMessagesAndContacts() { if (LoggedInUser != null && SelectedContact != null) { var messagesList = IMService.GetAllMessagesBetweenContacts(LoggedInUser, GetSelectedUser()); foreach (var message in messagesList) { if (MessagesCollection.Count(c => c.Id == message.Id) == 0) { MessagesCollection.Add(message); } } var contactsList = IMService.GetContacts(LoggedInUser); foreach (var contact in contactsList) { if (ContactsCollection.Count(c => c.Username == contact.Username) == 0) { ContactsCollection.Add(contact); AddToContactsDetails(contact); } } } }
public void AddAndInsertThrowsException() { var messages = new MessagesCollection(); Assert.Throws<NotSupportedException>(() => messages.Add(new Interfaces.Net.Message())); Assert.Throws<NotSupportedException>(() => messages.Insert(0, new Interfaces.Net.Message())); }