Пример #1
0
        protected override UserViewModel ReloadViewModel(UserViewModel viewModel)
        {
            var permissions = permissionProvider
                              .GetPermissions(UserId)
                              .Select(x => x.Action)
                              .ToList();

            if (!permissions.Contains(Permissions.GetActionKey(Module.Dashboard, Type.User, Action.Edit)) &&
                (viewModel.Id <= default(int) || UserId != viewModel.Id))
            {
                return(CreateViewModel(UserId.ToString()));
            }

            var roles = roleProvider.GetAll()
                        .OrderBy(x => x.Name)
                        .Where(x => x.Active)
                        .ToList();
            var userRoles          = roleProvider.GetRolesForUser(viewModel.Id);
            var userRoleViewModels = roles.Select(
                role => new RoleViewModel
            {
                Id     = role.Id,
                Name   = role.Name,
                Active = userRoles.Any(y => y.Id == role.Id)
            });

            viewModel.RoleNames.AddRange(userRoles.Select(x => x.Name));
            viewModel.Roles.AddRange(userRoleViewModels);

            return(viewModel);
        }
Пример #2
0
        /// <summary>
        /// Method to get project builder variables on the basis of tenantId.
        /// </summary>
        /// <param name="tenantId"></param>
        /// <returns>List of projectBuilderVariablesViewModel model.</returns>
        public ProjectBuilderVariablesViewModel GetProjectBuilderVariables(Guid tenantId)
        {
            ProjectBuilderVariablesViewModel projectBuilderVariablesViewModel = new ProjectBuilderVariablesViewModel();

            projectBuilderVariablesViewModel.VariableCategory = _VariableCategoryProvider.GetAll(tenantId);
            projectBuilderVariablesViewModel.Role             = _RoleProvider.GetAll(tenantId);
            projectBuilderVariablesViewModel.VariableType     = _VariableTypeProvider.GetAll();
            projectBuilderVariablesViewModel.ValidationRule   = _ValidationRuleProvider.GetAll();

            return(projectBuilderVariablesViewModel);
        }
Пример #3
0
        protected override RoleViewModel CreateViewModel(int roleId)
        {
            RoleViewModel viewModel;

            var role = roleProvider.GetAll()
                       .Include(x => x.RolePermissions)
                       .ThenInclude(x => x.Permission)
                       .FirstOrDefault(x => x.Id == roleId);

            if (role.IsNullOrDefault())
            {
                viewModel = new RoleViewModel
                {
                    Id          = 0,
                    Name        = string.Empty,
                    Active      = true,
                    Permissions = new List <PermissionViewModel>()
                };

                LoadAllPermissions(viewModel, new List <Permission>());

                return(viewModel);
            }

            viewModel = new RoleViewModel
            {
                Id          = role.Id,
                Name        = role.Name,
                Active      = role.Active,
                Permissions = new List <PermissionViewModel>()
            };

            var permissions = role.RolePermissions
                              .Select(x => x.Permission)
                              .ToList();

            LoadAllPermissions(viewModel, permissions);

            return(viewModel);
        }
Пример #4
0
 public QueryResultList <RoleInfo> GetAllRoles()
 {
     return(provider.GetAll());
 }