public override async Task <List <OrganizationUnitDto> > Resolve(IResolveFieldContext context)
        {
            var query = _organizationUnitRepository.GetAll().AsNoTracking();

            context
            .ContainsArgument <long>(Args.Id, id => query             = query.Where(o => o.Id == id))
            .ContainsArgument <int?>(Args.TenantId, tenantId => query = query.Where(o => o.TenantId == tenantId.Value))
            .ContainsArgument <string>(Args.Code, code => query       = query.Where(o => o.Code == code));

            return(await ProjectToListAsync <OrganizationUnitDto>(query));
        }
Beispiel #2
0
        public override async Task <List <RoleDto> > Resolve(IResolveFieldContext context)
        {
            var query = _roleManager.Roles.AsNoTracking();

            context
            .ContainsArgument <int>(Args.Id, id => query            = query.Where(r => r.Id == id))
            .ContainsArgument <string>(Args.TenantId, name => query = query.Where(r => r.Name == name))
            .ContainsArgument <int?>(Args.Name, tenantId => query   = query.Where(r => r.TenantId == tenantId.Value));

            return(await ProjectToListAsync <RoleDto>(query));
        }
Beispiel #3
0
        private static IQueryable <User> FilterQuery(IQueryable <User> query, IResolveFieldContext context)
        {
            context
            .ContainsArgument <long>(Args.Id,
                                     id => query = query.Where(u => u.Id == id))
            .ContainsArgument <string>(Args.Name,
                                       name => query = query.Where(u => u.Name == name))
            .ContainsArgument <string>(Args.Surname,
                                       surname => query = query.Where(u => u.Surname == surname))
            .ContainsArgument <string>(Args.EmailAddress,
                                       email => query = query.Where(u => u.EmailAddress == email))
            .ContainsArgument <int?>(Args.RoleId,
                                     roleId => query = query.Where(u => u.Roles.Any(r => r.RoleId == roleId.Value)))
            .ContainsArgument <bool>(Args.OnlyLockedUsers,
                                     onlyLocked => query = query.WhereIf(onlyLocked,
                                                                         u => u.LockoutEndDateUtc.HasValue && u.LockoutEndDateUtc.Value > DateTime.UtcNow))
            .ContainsArgument <string>(Args.Filter, filter => query = query.WhereIf(!string.IsNullOrWhiteSpace(filter),
                                                                                    u => u.Name.Contains(filter) ||
                                                                                    u.Surname.Contains(filter) ||
                                                                                    u.UserName.Contains(filter) ||
                                                                                    u.EmailAddress.Contains(filter)));

            return(query);
        }