public static bool IsAdministrator(User u) { RoleManagementService roleManagementService = new RoleManagementService(RoleManagementService.Application); IEnumerable<Role> userRoles = roleManagementService.FindRoles(u.Id); Role adminRole = userRoles.FirstOrDefault(r => r.Name == Settings.Default.AdministratorRoleName); return adminRole != null; }
public void SetUp() { ServiceLocatorInitializer.Init(); roleRepository = MockRepository.GenerateMock <IRoleRepository>(); roleRepository.Stub(r => r.DbContext) .Return(MockRepository.GenerateMock <IDbContext>()); roleManagementService = new RoleManagementService(roleRepository); }
public EmployeeModel() { _employeeManagementService = new EmployeeManagementService(); Employees = GetAllEmployee(); _branchManagementService = new BranchManagementService(); Branches = GetAllBranch(); _companyManagementService = new CompanyManagementService(); Companies = GetAllCompanies(); _departmentManagementService = new DepartmentManagementService(); Departments = GetAllDepartment(); _positionManagementService = new PositionManagementService(); Positions = GetAllPosition(); _roleManagementService = new RoleManagementService(); Roles = GetAllRole(); }
//List IT roles registered in LifeTime public static void Main(string[] args) { // Use the AuthenticationService API to get a session token. // See its implementation on the Authorization Service API String token = AuthenticationExample.getToken(); // Create an authentication object to send in the WS call and set it with the session token WebServiceSimpleAuthentication authentication = new WebServiceSimpleAuthentication(); authentication.Token = token; // Role Management Service WS proxy created by Visual Studio RoleManagementService service = new RoleManagementService(); // The status of the WS call bool success = false; APIStatus status = null; PlatformRole[] roles = null; //Invoke the Role_List web method success = service.Role_List(authentication, out status, out roles); //If the call was successful, print information about the role if (success) { foreach (PlatformRole role in roles) { Console.WriteLine(String.Format("{0,-20}{1}", role.Name, role.Description)); } } else { // Implement error handling by checking the status.ResponseId field // See the possible error codes in the APIStatus structure documentation } }
//List IT roles registered in LifeTime public static void Main(string[] args) { // Use the AuthenticationService API to get a session token. // See its implementation on the Authorization Service API String token = AuthenticationExample.getToken(); // Create an authentication object to send in the WS call and set it with the session token WebServiceSimpleAuthentication authentication = new WebServiceSimpleAuthentication(); authentication.Token = token; // Role Management Service WS proxy created by Visual Studio RoleManagementService service = new RoleManagementService(); // The status of the WS call bool success = false; APIStatus status = null; EnvironmentPermissionForRole[] permissions = null; //Invoke the Role_GetPermissions web method for the Developer role success = service.Role_GetPermissions(authentication, "Developer", out status, out permissions); //If the call was successful, print information about the role if (success) { foreach (EnvironmentPermissionForRole permission in permissions) { Console.WriteLine(String.Format("{0,-20}{1}", permission.EnvironmentName, permission.EnvironmentPermissionLevelId)); } } else { // Implement error handling by checking the status.ResponseId field // See the possible error codes in the APIStatus structure documentation } }
//public Guid? CompanyId { get; set; } //public List<EmployeeEducationHistory> EducationHistories { get; set; } public RoleModel() { _roleManagementService = new RoleManagementService(); RoleTasks = RoleTaskCheckBoxModel.TaskNames.OrderBy(x => x.TaskName).ToList(); }
public RoleController(ILibraryDbContext dbContext, UserManagementService userService, RoleManagementService roleService) : base(dbContext) { _userService = userService; _roleService = roleService; }