partial void DeleteMessageDataProvider(MessageDataProvider instance);
partial void UpdateMessageDataProvider(MessageDataProvider instance);
private void detach_MessageDataProviders(MessageDataProvider entity) { this.SendPropertyChanging(); entity.UserDataProvider = null; }
partial void InsertMessageDataProvider(MessageDataProvider instance);
/// <summary> /// Updates a Group's the list of Recent Acitivity Messages in the Database. /// </summary> /// <param name="group">The Group for which to update Recent Activity Messages</param> public static bool UpdateGroupRecentActivity(Group group) { int groupId = group.ID; try { using (SqlConnection connection = ConnectionManager.GetConnection()) { var data = new ActivEarthDataProvidersDataContext(connection); List<MessageDataProvider> messages = (from m in data.MessageDataProviders where m.group_id == groupId select m ).ToList(); foreach (MessageDataProvider messageData in messages) { bool found = false; foreach (Message message in group.Wall.Messages) { if (messageData.message == message.Text && messageData.user_id == message.Poster.UserID && messageData.title == message.Title && messageData.time == message.Time && messageData.date == message.Date) { found = true; } } if (!found) { data.MessageDataProviders.DeleteOnSubmit(messageData); } } foreach (Message message in group.Wall.Messages) { bool found = false; foreach (MessageDataProvider messageData in messages) { if (messageData.message == message.Text && messageData.user_id == message.Poster.UserID && messageData.title == message.Title && messageData.time == message.Time && messageData.date == message.Date) { found = true; } } if (!found) { MessageDataProvider messageData = new MessageDataProvider { title = message.Title, message = message.Text, user_id = message.Poster.UserID, group_id = groupId, date = message.Date, time = message.Time }; data.MessageDataProviders.InsertOnSubmit(messageData); } } data.SubmitChanges(); return true; } } catch(Exception) { return false; } }