Exemple #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);
            }
        }
Exemple #2
0
        public static void DeleteNoteType(NoteType toDelete)
        {
            using (ProMaDB scope = new ProMaDB())
            {
                foreach (PostedNote curNote in PostedNoteHandler.GetAllNotesOfType(toDelete.NoteTypeId))
                {
                    PostedNote updateThis = PostedNoteHandler.GetNote(curNote.NoteId);
                    updateThis.NoteTypeId = null;
                    updateThis.Active     = false;
                    PostedNoteHandler.UpdatePostedNote(updateThis);
                }

                foreach (NoteTypeMembership membership in NoteTypeMembershipHandler.GetMembershipsForType(toDelete.NoteTypeId))
                {
                    NoteTypeMembershipHandler.RemoveNoteTypeMembership(membership);
                }

                scope.NoteTypes.Attach(toDelete);
                scope.NoteTypes.Remove(toDelete);

                scope.SaveChanges();

                ThisCache.Remove(toDelete);
            }
        }