public async Task <PagedResponse <ServiceUserResponse> > GetServiceUsers(ServiceUserQueryParameters parameters)
        {
            var result = await _serviceUserGateway.GetServiceUserInformation(parameters).ConfigureAwait(false);

            return(new PagedResponse <ServiceUserResponse>
            {
                PagingMetaData = result.PagingMetaData,
                Data = result.ToResponse()
            });
        }
Esempio n. 2
0
        public async Task <PagedList <ServiceUserDomain> > GetServiceUserInformation(ServiceUserQueryParameters queryParameters)
        {
            var serviceUserIds = await _databaseContext.CarePackages
                                 .Where(p => p.Status != PackageStatus.Cancelled &&
                                        p.Status != PackageStatus.Ended)
                                 .Select(p => p.ServiceUserId)
                                 .Distinct()
                                 .ToListAsync();

            var serviceUsers = await _databaseContext.ServiceUsers
                               .FilterServiceUser(serviceUserIds, queryParameters.FirstName, queryParameters.LastName, queryParameters.PostCode,
                                                  queryParameters.DateOfBirth, queryParameters.HackneyId, queryParameters.HasPackages)
                               .Skip((queryParameters.PageNumber - 1) * queryParameters.PageSize)
                               .Take(queryParameters.PageSize)
                               .AsNoTracking()
                               .ToListAsync();

            var serviceUserCount = await _databaseContext.ServiceUsers
                                   .FilterServiceUser(serviceUserIds, queryParameters.FirstName, queryParameters.LastName, queryParameters.PostCode,
                                                      queryParameters.DateOfBirth, queryParameters.HackneyId, queryParameters.HasPackages)
                                   .CountAsync();

            return(PagedList <ServiceUserDomain> .ToPagedList(serviceUsers.ToDomain(), serviceUserCount, queryParameters.PageNumber, queryParameters.PageSize));
        }