Exemplo n.º 1
0
        public IdentityResult DeleteGroup(string groupId)
        {
            var group = this.FindById(groupId);

            if (group == null)
            {
                throw new ArgumentNullException("User");
            }

            var currentGroupMembers = this.GetGroupUsers(groupId).ToList();

            // remove the roles from the group:
            group.ApplicationRoles.Clear();

            // Remove all the users:
            group.ApplicationUsers.Clear();

            // Remove the group itself:
            _db.ApplicationGroups.Remove(group);

            _db.SaveChanges();

            // Reset all the user roles:
            foreach (var user in currentGroupMembers)
            {
                this.RefreshUserGroupRoles(user.Id);
            }
            return(IdentityResult.Success);
        }
        public virtual void Activate(int id)
        {
            var entity = new T()
            {
                Id = id, IsActivated = true
            };
            var dbSet = DbContext.Set <T>();

            dbSet.Attach(entity);
            DbEntityEntry dbEntityEntry = DbContext.Entry <T>(entity);

            DbContext.Entry <T>(entity).Property(a => a.IsActivated).IsModified = true;
            DbContext.SaveChanges();
        }
        public IdentityResult SetPageParentsChildern(
            long pageId,
            long[] childern)
        {
            var thisPage = this.GetPageWithRelations(pageId);

            thisPage.ChildernPages.Clear();
            _db.SaveChanges();

            if (childern != null && childern.Any())
            {
                thisPage.ChildernPages = _db.ApplicationPages.Where(p => childern.Contains(p.ApplicationPageId)).ToList();
            }

            _db.SaveChanges();

            return(IdentityResult.Success);
        }