コード例 #1
0
        public static ICollection<User> GetAll()
        {
            List<User> userList = new List<User>();
            List<Feature> allFeatures = Feature.GetAll().ToList();

            for (int i = 1; i <= Constants.USERSCOUNT; i++)
            {
                int adminOrUserRole = new Random().Next(1, 2);
                //int precedingNumFeaturesToAssign = new Random().Next(0, Constants.FEATURESCOUNT + 1);

                User uT = new User();
                uT.ID = i;
                uT.RoleID = adminOrUserRole;
                uT.Email = "email_" + i + "@gmail.com";
                uT.FullName = "Name_" + i;
                uT.IsActive = true;

                //uT.AllowedFeatures.AddRange(allFeatures.Where(f => f.ID < precedingNumFeaturesToAssign));

                userList.Add(uT);
            }

            return userList;
        }
コード例 #2
0
        public static void setPermissions(User loggedInUser)
        {
            PermissionManager userPermissions = new PermissionManager();
            Service service = new Service();
            User loginContact = loggedInUser;

            userPermissions.loggedInUserContact = loginContact;
            userPermissions.assignedRole = loginContact.Role;
            //userPermissions.accessibleFeatures = service.GetAccessibleFeaturesForUser(loginContact);
            userPermissions.accessibleFeatures = service.SetFeaturesToLoginUser().ToList();

            SessionManager.setSession<PermissionManager>(PERMISSION_SESSIONNAME, userPermissions);
        }
コード例 #3
0
ファイル: Service.cs プロジェクト: bcnu/MVCAndJSSecurityApp
 internal List<Feature> GetAccessibleFeaturesForUser(User loginContact)
 {
     return (db.Users.Where(u => u.ID == loginContact.ID).FirstOrDefault().AllowedFeatures);
 }