Пример #1
0
        public static void PermanentlyDeleteUser(ProMaUser toDelete)
        {
            using (ProMaDB scope = new ProMaDB())
            {
                foreach (PostedNote currentNote in PostedNoteHandler.GetNotes
                             (shownToUser: toDelete.UserId, includeInactive: true, onlyInactive: false, includeComplete: true, onlyThisNoteId: -1, includeHibernatedNotes: true))
                {
                    PostedNoteHandler.PermanentlyDeleteNote(currentNote);
                }

                foreach (NoteType currentNoteType in NoteTypeHandler.GetNoteTypesForUser(toDelete.UserId))
                {
                    NoteTypeHandler.DeleteNoteType(currentNoteType);
                }

                foreach (SharedChoreMembership currentSharedChoreMembership in SharedChoreMembershipHandler.GetSharedChoreMembershipsForUser(toDelete.UserId))
                {
                    SharedChoreHandler.PermanentlyDeleteSharedChore(currentSharedChoreMembership.SharedChoreId);
                }

                foreach (CalendarEntry currentCalendarEntry in CalendarHandler.GetAllCalendarEntriesForUser(toDelete.UserId))
                {
                    CalendarHandler.DeleteCalendar(currentCalendarEntry.CalendarId);
                }

                scope.ProMaUsers.Remove(toDelete);
                scope.SaveChanges();

                ThisCache.Remove(toDelete);
            }
        }
Пример #2
0
        public static void PermanentlyDeleteSharedChore(int sharedChoreId)
        {
            using (ProMaDB scope = new ProMaDB())
            {
                SharedChore sharedChore = SharedChoreHandler.GetSharedChore(sharedChoreId);

                foreach (CompletedChore currentCompletedChore in CompletedChoreHandler.GetAllCompletedChoreItems(sharedChore.SharedChoreId))
                {
                    CompletedChoreHandler.UnCompleteChore(sharedChore.SharedChoreId, currentCompletedChore.ChoreDate);
                }

                foreach (SharedChoreMembership currentSharedChoreMembership in SharedChoreMembershipHandler.GetSharedChoreMembershipsForChore(sharedChoreId))
                {
                    SharedChoreMembershipHandler.RemoveSharedChoreMembership(sharedChoreId, currentSharedChoreMembership.UserId);
                }

                scope.Remove(sharedChore);
                scope.SaveChanges();
            }
        }