예제 #1
0
        protected void AddGroupRole(GroupEntityModel group, ApplicationRoles role)
        {
            // Add Group to Role.
            var groupRole = new GroupRoleEntityModel
            {
                Group     = group,
                Role      = Context.Roles.Find(role.GetEnumGuid()),
                CreatedBy = User
            };

            Context.GroupRoles.Add(groupRole);
            Context.SaveChanges();
            Trace.WriteLine($"Added Role to Group -> {role} => {group.Name}");
        }
예제 #2
0
        protected void AddUserRole(UserEntityModel user, ApplicationRoles role)
        {
            // Add User Roles.
            var showAllRole = new UserRoleEntityModel
            {
                RoleId = role.GetEnumGuid(),
                User   = user
            };

            Context.UserRoles.Add(showAllRole);
            Context.SaveChanges();

            // Reload Factory.
            Factory = new ServiceFactory(Context, Identity);

            Trace.WriteLine($"Added '{role}' Role to User -> {user.UserName}");
        }