public virtual async Task <ListResultDto <IdentityRoleDto> > GetRolesAsync(Guid id)
        {
            var ou = await OrganizationUnitRepository.GetAsync(id, false);

            return(new ListResultDto <IdentityRoleDto>(
                       ObjectMapper.Map <List <IdentityRole>, List <IdentityRoleDto> >(
                           await OrganizationUnitRepository.GetRolesAsync(ou)
                           )));
        }
Exemplo n.º 2
0
        public virtual async Task <PagedResultDto <IdentityRoleDto> > GetRolesAsync(OrganizationUnitGetRoleByPagedDto input)
        {
            var origanizationUnit = await OrganizationUnitRepository.GetAsync(input.Id);

            var origanizationUnitRoleCount = await OrganizationUnitRepository.GetRolesCountAsync(origanizationUnit);

            var origanizationUnitRoles = await OrganizationUnitRepository.GetRolesAsync(origanizationUnit,
                                                                                        input.Sorting, input.MaxResultCount, input.SkipCount, false);

            return(new PagedResultDto <IdentityRoleDto>(origanizationUnitRoleCount,
                                                        ObjectMapper.Map <List <IdentityRole>, List <IdentityRoleDto> >(origanizationUnitRoles)));
        }
        private async Task <List <IdentityRole> > GetOrganizationUnitRoles(Guid organizationUnitId)
        {
            var ou = await OrganizationUnitRepository.GetAsync(organizationUnitId, false);

            var ouRoles = await OrganizationUnitRepository.GetRolesAsync(ou);

            if (ouRoles.Any())
            {
                return(ouRoles);
            }
            else
            {
                if (ou.ParentId.HasValue)
                {
                    return(await GetOrganizationUnitRoles(ou.ParentId.Value));
                }
                else
                {
                    return(ouRoles);
                }
            }
        }