Exemple #1
0
        private static void DeleteUserInternal(JavnaRasprava.WEB.DomainModels.ApplicationUser user, DomainModels.ApplicationDbContext context)
        {
            context.LawComments.Where(x => x.ApplicationUserID == user.Id).Delete();
            context.LawCommentLikes.Where(x => x.ApplicationUserID == user.Id).Delete();
            context.LawVotes.Where(x => x.ApplicationUserID == user.Id).Delete();
            context.LawSectionVotes.Where(x => x.ApplicationUserID == user.Id).Delete();
            context.PetitionSignatures.Where(x => x.ApplicationUserID == user.Id).Delete();
            context.Petitions.Where(x => x.SubmitterUserID == user.Id).Delete();

            context.Users.Remove(user);
        }
Exemple #2
0
        public void DeleteUser(JavnaRasprava.WEB.DomainModels.ApplicationUser user)
        {
            using (var context = JavnaRasprava.WEB.DomainModels.ApplicationDbContext.Create())
            {
                context.Users.Attach(user);

                DeleteUserInternal(user, context);

                context.SaveChanges();
            }
        }