public virtual ActionResult Index(string tabId, int parentId) { var result = Service.InitList(parentId); var model = PermissionListViewModel.Create(result, tabId, parentId, Service, ControllerName); return(JsonHtml("EntityPermissionIndex", model)); }
public async Task <PartialViewResult> CreateRoleModal() { var roles = (await _roleAppService.GetRolesAsync(new GetRolesInput())).Items; var permissions = (await _roleAppService.GetAllPermissions()).Items; var viewModel = new PermissionListViewModel() { Permissions = permissions }; return(PartialView("_CreateRoleModal", viewModel)); }
public void SavePermissions(IUnitOfWork uow) { IEnumerable <EntitySubdivisionOnlyPermission> permissionList = PermissionListViewModel.PermissionsList .Select(x => x.EntityPermission) .OfType <EntitySubdivisionOnlyPermission>(); foreach (var item in permissionList) { uow.Save(item); } PermissionListViewModel.SaveExtendedPermissions(uow); }
public void Save() { foreach (EntityUserPermission item in PermissionListViewModel.PermissionsList.Select(x => x.EntityPermission as EntityUserPermission).Where(x => x != null)) { uow.Save(item); PermissionListViewModel.SaveExtendedPermissions(uow); } foreach (var item in deletePermissionList) { uow.Delete <EntityUserPermission>(item.EntityPermission as EntityUserPermission); foreach (var extendedPermission in item.EntityPermissionExtended) { uow.Delete(extendedPermission); } } }
public async Task <ActionResult> Index(int?id) { var allRoles = await _roleService.GetAllAsync(); var model = new PermissionListViewModel { Roles = allRoles }; var role = await _roleService.GetByIdIncludePermissionsAsync(id ?? 0); if (role != null) { model.RoleId = role.Id; model.Tabs = PermissionHelper.GetPermissionTabViewModels(role.Permissions); } return(View(model)); }
public async Task <ActionResult> Index(int?id) { var allRoles = await _mediator.Send(new GetAllRoles.Query()); var model = new PermissionListViewModel { Roles = allRoles }; var role = await _mediator.Send(new GetRoleByIdIncludePermissions.Query { Id = id ?? 0 }); if (role != null) { model.RoleId = role.Id; model.PermissionTabs = PermissionHelper.GetPermissionTabViewModels(role.Permissions); } return(View(model)); }
public EntityUserPermissionModel(IUnitOfWork uow, UserBase user, PermissionListViewModel permissionListViewModel) { this.user = user; this.uow = uow; this.PermissionListViewModel = permissionListViewModel ?? throw new NullReferenceException(nameof(permissionListViewModel)); permissionList = UserPermissionRepository.GetUserAllEntityPermissions(uow, user.Id, permissionListViewModel.PermissionExtensionStore); PermissionListViewModel.PermissionsList = new GenericObservableList <IPermissionNode>(permissionList.OfType <IPermissionNode>().ToList()); PermissionListViewModel.PermissionsList.ElementRemoved += (aList, aIdx, aObject) => DeletePermission(aObject as UserPermissionNode); originalTypeOfEntityList = TypeOfEntityRepository.GetAllSavedTypeOfEntity(uow).ToList(); //убираем типы уже загруженные в права foreach (var item in permissionList) { if (originalTypeOfEntityList.Contains(item.TypeOfEntity)) { originalTypeOfEntityList.Remove(item.TypeOfEntity); } } SortTypeOfEntityList(); ObservableTypeOfEntitiesList = new GenericObservableList <TypeOfEntity>(originalTypeOfEntityList); }
public EntitySubdivisionPermissionModel(IUnitOfWork uow, Subdivision subdivision, PermissionListViewModel permissionListViewModel, IPermissionRepository permissionRepository) { PermissionListViewModel = permissionListViewModel ?? throw new NullReferenceException(nameof(permissionListViewModel)); this.subdivision = subdivision; this.uow = uow; ExtensionStore = PermissionListViewModel.PermissionExtensionStore; var permissionList = permissionRepository.GetAllSubdivisionEntityPermissions(uow, subdivision.Id, ExtensionStore); originalPermissionList = permissionList.ToList(); PermissionListViewModel.PermissionsList = new GenericObservableList <IPermissionNode>(permissionList.OfType <IPermissionNode>().ToList()); PermissionListViewModel.PermissionsList.ElementRemoved += (aList, aIdx, aObject) => DeletePermission(aObject as SubdivisionPermissionNode); originalTypeOfEntityList = TypeOfEntityRepository.GetAllSavedTypeOfEntity(uow).ToList(); //убираем типы уже загруженные в права foreach (var item in originalPermissionList) { if (originalTypeOfEntityList.Contains(item.TypeOfEntity)) { originalTypeOfEntityList.Remove(item.TypeOfEntity); } } SortTypeOfEntityList(); ObservableTypeOfEntitiesList = new GenericObservableList <TypeOfEntity>(originalTypeOfEntityList); }