public Task <PagedResponse <MemberSummary> > Handle(GetMemberListQuery request, CancellationToken cancellationToken)
        {
            var query = _datingAppDbContext.Users.Where(u => u.Id != request.User.Id);

            query = ApplyGenderFilter(query, request.Gender, request.User.Gender);
            query = ApplyAgeFilter(query, request.MinAge, request.MaxAge);

            IOrderedQueryable <User> orderedQuery = request.OrderBy switch
            {
                SortableField.Created => query.OrderByDescending(u => u.Created),
                SortableField.LastActive => query.OrderByDescending(u => u.LastActive),
                _ => query.OrderByDescending(u => u.LastActive)
            };

            var projectedQuery = orderedQuery
                                 .ThenBy(m => m.Id)
                                 .AsNoTracking()
                                 .Select(u => new MemberSummary(
                                             u.Id,
                                             u.Name,
                                             u.City,
                                             u.Photos.FirstOrDefault(p => p.IsMain)
                                             ));

            return(PagedResponse <MemberSummary> .Create(projectedQuery, request.PageNumber, request.PageSize));
        }
Beispiel #2
0
        public async Task <PagedResponse <AssetModel, AssetModel> > Handle(
            AssetsRequest request,
            CancellationToken cancellationToken)
        {
            var items = _ctx.Assets.AsQueryable();

            if (request.ArticleId != null)
            {
                items = items.Where(x => x.ArticleId == request.ArticleId);
            }

            if (!string.IsNullOrEmpty(request.Lmid))
            {
                items = items.Where(x => x.LMID == request.Lmid);
            }
            else
            {
                items = items.Where(x => x.HolderTenantId == request.TenantId);
            }

            if (!string.IsNullOrEmpty(request.Purpose))
            {
                items = items
                        .Where(x => x.Purposes.Select(x => x.PurposeId.ToString()).Contains(request.Purpose));
            }

            var result = items.GetAssetModels().OrderBy(x => x.Lmid).AsNoTracking();

            return(await PagedResponse <AssetModel, AssetModel> .Create(
                       item => item,
                       result,
                       request.PaginationParameters.PageNumber,
                       request.PaginationParameters.PageSize,
                       cancellationToken));
        }
Beispiel #3
0
        public PagedResponse <CompanyBasicProfile, CompanySortColumn> SearchCompanies(CompanySearchParameters searchDetails)
        {
            //TODO:: Stub - Fetch
            var response = new List <CompanyBasicProfile> {
            };

            return(PagedResponse <CompanyBasicProfile, CompanySortColumn> .Create(response, ResultCode.Success));
        }
        public async Task <PagedResponse <AssetLocation, LocationModel> > Handle(LocationsRequest request, CancellationToken cancellationToken)
        {
            var query = _ctx.AssetLocations.Where(x => x.AssetId == request.AssetId).AsNoTracking();

            return(await PagedResponse <AssetLocation, LocationModel> .Create(
                       MapFrom,
                       query,
                       request.PaginationParameters.PageNumber,
                       request.PaginationParameters.PageSize,
                       cancellationToken));
        }
 PagedResponse <CompanyBasicProfile, CompanySortColumn> ICompanyService.SearchCompanies(CompanySearchParameters searchDetails)
 {
     try
     {
         return(Delegator.SearchCompanies(searchDetails));
     }
     catch (Exception ex)
     {
         return(PagedResponse <CompanyBasicProfile, CompanySortColumn> .Create(null, ResultCode.GeneralFailure, ex.Message));
     }
 }
        public async Task <PagedResponse <Event, SearchReservationModel> > Handle(
            ReservationsRequest request,
            CancellationToken cancellationToken)
        {
            IQueryable <Event> query = _ctx.Events;

            if (request.ReservationQueryParameters != null)
            {
                query     = ApplyFilters(query, request.ReservationQueryParameters, request.TenantId, request.AssetId);
                IsCompact = request.ReservationQueryParameters.Compact;
            }

            return(await PagedResponse <Event, SearchReservationModel> .Create(
                       MapFrom,
                       query,
                       request.PaginationParameters.PageNumber,
                       request.PaginationParameters.PageSize,
                       cancellationToken));
        }