Ejemplo n.º 1
0
 public virtual void Update(ApplicationGroup entity)
 {
     if (entity != null)
     {
         this.Context.Entry<ApplicationGroup>(entity).State = EntityState.Modified;
     }
 }
Ejemplo n.º 2
0
 public virtual async Task DeleteAsync(ApplicationGroup group)
 {
     this.ThrowIfDisposed();
     if (group == null)
     {
         throw new ArgumentNullException("group");
     }
     this._groupStore.Delete(group);
     await this.Context.SaveChangesAsync();
 }
Ejemplo n.º 3
0
 public virtual void Delete(ApplicationGroup group)
 {
     this.ThrowIfDisposed();
     if (group == null)
     {
         throw new ArgumentNullException("group");
     }
     this._groupStore.Delete(group);
     this.Context.SaveChanges();
 }
Ejemplo n.º 4
0
        public static void SeedIdentityForEF(ApplicationDbContext context)
        {
            if ((!context.Roles.Any()) && (!context.Users.Any()))
            {
                var roleStore = new ApplicationRoleStore(context);
                //var roleManager = new RoleManager<ApplicationRole, int>(roleStore);

                var roleManager = new ApplicationRoleManager(roleStore);

                var role = new ApplicationRole
                {
                    Name = "Admin",
                    Description = "Super Admin User group"
                };
                roleManager.Create(role);

                var userStore = new UserStore<ApplicationUser,
                                                ApplicationRole,
                                                int,
                                                ApplicationUserLogin,
                                                ApplicationUserRole,
                                                ApplicationUserClaim>(context);
                var userManager = new ApplicationUserManager(userStore);

                var user = new ApplicationUser
                {
                    Email = "*****@*****.**",
                    UserName = "******",
                    EmailConfirmed = true
                };

                user.FirstName = "Jack";
                user.LastName = "Smith";

                userManager.Create(user, "P@ssword");
                var result = userManager.SetLockoutEnabled(user.Id, false);

                userManager.AddToRole(user.Id, "Admin");

                //added group manager
                var groupManager = new ApplicationGroupManager(roleManager,userManager);
                var newGroup = new ApplicationGroup("SuperAdmins", "Full Access to All");

                groupManager.CreateGroup(newGroup);
                groupManager.SetUserGroups(user.Id, new int[] { newGroup.Id });
                groupManager.SetGroupRoles(newGroup.Id, new string[] { role.Name });
            }
        }
Ejemplo n.º 5
0
 public void Delete(ApplicationGroup entity)
 {
     this.DbEntitySet.Remove(entity);
 }
Ejemplo n.º 6
0
 public void Create(ApplicationGroup entity)
 {
     this.DbEntitySet.Add(entity);
 }
Ejemplo n.º 7
0
 public IdentityResult CreateGroup(ApplicationGroup group)
 {
     _groupStore.Create(group);
     return IdentityResult.Success;
 }
Ejemplo n.º 8
0
 public async Task<IdentityResult> CreateGroupAsync(ApplicationGroup group)
 {
     await _groupStore.CreateAsync(group);
     return IdentityResult.Success;
 }
Ejemplo n.º 9
0
 public IdentityResult UpdateGroup(ApplicationGroup group)
 {
     _groupStore.Update(group);
     foreach (var groupUser in group.ApplicationUsers)
     {
         this.RefreshUserGroupRoles(groupUser.ApplicationUserId);
     }
     return IdentityResult.Success;
 }
Ejemplo n.º 10
0
 public async Task<IdentityResult> UpdateGroupAsync(ApplicationGroup group)
 {
     await _groupStore.UpdateAsync(group);
     foreach (var groupUser in group.ApplicationUsers)
     {
         await this.RefreshUserGroupRolesAsync(groupUser.ApplicationUserId);
     }
     return IdentityResult.Success;
 }