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; }
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); }
internal List<Feature> GetAccessibleFeaturesForUser(User loginContact) { return (db.Users.Where(u => u.ID == loginContact.ID).FirstOrDefault().AllowedFeatures); }