Пример #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);
            }
        }