Ejemplo n.º 1
0
        public virtual async Task <ListResultDto <OrganizationUnitDto> > FindChildrenAsync(OrganizationUnitGetChildrenDto input)
        {
            var origanizationUnitChildren = await OrganizationUnitManager.FindChildrenAsync(input.Id, input.Recursive);

            return(new ListResultDto <OrganizationUnitDto>(
                       ObjectMapper.Map <List <OrganizationUnit>, List <OrganizationUnitDto> >(origanizationUnitChildren)));
        }
Ejemplo n.º 2
0
        public virtual async Task <ListResultDto <OrganizationUnitDto> > GetRootAsync()
        {
            var rootOriganizationUnits = await OrganizationUnitManager.FindChildrenAsync(null, recursive : false);

            return(new ListResultDto <OrganizationUnitDto>(
                       ObjectMapper.Map <List <OrganizationUnit>, List <OrganizationUnitDto> >(rootOriganizationUnits)));
        }
Ejemplo n.º 3
0
        public virtual async Task <IQueryable <IdentityUser> > CreateFilteredQueryAsync(GetIdentityUsersDetailsInput input)
        {
            var query = await _repository.WithDetailsAsync();

            if (input.OrganizationUnitId != null)
            {
                var code = await UnitManager.GetCodeOrDefaultAsync(input.OrganizationUnitId.Value);

                var organizationUnitIds = (await UnitManager.FindChildrenAsync(input.OrganizationUnitId.Value, true)).Select(x => x.Id).ToList();
                organizationUnitIds.Add(input.OrganizationUnitId.Value);
                query = query.Where(x => x.OrganizationUnits.Any(o => organizationUnitIds.Contains(o.OrganizationUnitId)));
            }
            return(query
                   .WhereIf(
                       !input.Filter.IsNullOrWhiteSpace(),
                       u =>
                       u.UserName.Contains(input.Filter) ||
                       u.Email.Contains(input.Filter) ||
                       (u.Name != null && u.Name.Contains(input.Filter)) ||
                       (u.Surname != null && u.Surname.Contains(input.Filter)) ||
                       (u.PhoneNumber != null && u.PhoneNumber.Contains(input.Filter))
                       )
                   .WhereIf(input.RoleId != null, u => u.Roles.Any(x => x.RoleId == input.RoleId))
                   //.WhereIf(input.OrganizationUnitId != null, u => u.OrganizationUnits.Any(x => x.OrganizationUnitId == input.OrganizationUnitId))
                   );
        }
        public async Task <List <OrganizationUnitDto> > GetOrganizationUnits()
        {
            var units = ObjectMapper.Map <List <OrganizationUnitDto> >(await _organizationUnitManager.FindChildrenAsync(null, true));

            foreach (var organizationUnitDto in units)
            {
                organizationUnitDto.MemberCount = _userOrgRepository.Count(uou => uou.OrganizationUnitId == organizationUnitDto.Id);
            }
            return(units);
        }
        private async Task <List <OrganizationUnitDto> > GetChildren(OrganizationUnit organizationUnit)
        {
            var childs = new List <OrganizationUnitDto>();

            var children = await _organizationUnitManager.FindChildrenAsync(organizationUnit.Id);

            foreach (var child in children)
            {
                var childElement = child.MapTo <OrganizationUnitDto>();
                childElement.ChildrenDto = await GetChildren(child);

                childs.Add(childElement);
            }

            return(childs);
        }