internal void RemoveUserFromProject(IncomingRemoveUserFromProject userProject) { var userAccount = Context.AssociatedProjectMembers.FirstOrDefault(x => x.ProjectId == userProject.ProjectId && x.UserAccountId == userProject.UserId); Context.Attach(userAccount); Context.Remove(userAccount); Context.SaveChanges(); }
internal void RemoveChatCategory(int id) { var chatChannels = Context.ChatChannels.Where(x => x.ChatRoom == id).ToList(); chatChannels.ForEach(x => { var associatedMessage = Context.AssociatedChatChannelMessages.Where(y => y.ChatChannelId == x.Id).ToList(); Context.RemoveRange(associatedMessage); var notifications = Context.AssociatedUserChatNotifications.Where(y => y.ChatChannelId == x.Id).ToList(); Context.RemoveRange(notifications); Context.SaveChanges(); }); Context.RemoveRange(chatChannels); Context.SaveChanges(); var AssociatedChatRoomRights = Context.AssociatedChatRoomRights.Where(x => x.ChatRoomId == id).ToList(); Context.RemoveRange(AssociatedChatRoomRights); Context.SaveChanges(); var category = Context.ChatRooms.FirstOrDefault(x => x.Id == id); Context.Remove(category); Context.SaveChanges(); }