예제 #1
0
        //[AbpAuthorize(PermissionNames.AdminPage_JobSeeker)]
        public virtual async Task <PagedResultDto <JobSeekerDto> > GetAllBoxDto(JobSeekerFilterDto input)
        {
            //giờ lấy danh sách serkerid từ category
            var jobseekerWithCategoryIds = jobCategoryRepository
                                           .GetAll()
                                           .WhereIf(input.CategoryId != null, p => p.CategoryId == input.CategoryId)
                                           .Select(p => p.JobSeekerId)
                                           .Distinct()
                                           .ToList();

            //lấy danh sách seekerid từ cityid

            var jobseekerWithCityIds = locationJobRepository
                                       .GetAll()
                                       .WhereIf(input.JobLocationId != null, p => p.CityId == input.JobLocationId)
                                       .Select(p => p.JobSeekerId)
                                       .Distinct()
                                       .ToList();

            //giao 3 mảng lại dc danh sách seekerids
            //chỗ này e tìm cách viết ra 1 tập hơp jobseekerids
            //lấy data từ danh sách đó

            var jobseekerids = jobseekerWithCityIds.Intersect(jobseekerWithCategoryIds);
            //jobseekerids = jobseekerids.Intersect(jobseekerWithExperince);


            var query = jobSeekerRepository
                        .GetAll()
                        .Where(p => jobseekerids.Contains(p.Id))
                        .WhereIf(input.Name != null, p => p.Name == input.Name)
                        .Where(p => p.IsActive == true);


            //var query = jobSeekerRepository.GetAll()
            //     .WhereIf(input.Id != null, p => p.Id == input.Id);

            var totalCount = await query.CountAsync();

            query = ApplySorting(query, input);
            query = ApplyPaging(query, input);

            var entities = await query.ToListAsync();

            return(new PagedResultDto <JobSeekerDto>(
                       totalCount,
                       entities.Select(p => p.MapTo <JobSeekerDto>())
                       .ToList()
                       ));
        }
예제 #2
0
        public virtual async Task <PagedResultDto <JobSeekerDto> > GetAll(JobSeekerFilterDto input)
        {
            var query = jobSeekerRepository.GetAll()
                        .WhereIf(input.Id != null, p => p.Id == input.Id)
                        .WhereIf(input.Name != null, p => p.Name == input.Name);

            var totalCount = await query.CountAsync();

            query = ApplySorting(query, input);
            query = ApplyPaging(query, input);

            var entities = await query.ToListAsync();

            return(new PagedResultDto <JobSeekerDto>(
                       totalCount,
                       entities.Select(p => p.MapTo <JobSeekerDto>())
                       .ToList()
                       ));
        }
예제 #3
0
        protected virtual IQueryable <JobSeeker> ApplyPaging(IQueryable <JobSeeker> query, JobSeekerFilterDto input)
        {
            var pagedInput = input as IPagedResultRequest;

            if (pagedInput != null)
            {
                return(query.PageBy(pagedInput));
            }

            var limitedInput = input as ILimitedResultRequest;

            if (limitedInput != null)
            {
                return(query.Take(limitedInput.MaxResultCount));
            }

            return(query);
        }
예제 #4
0
        protected virtual IQueryable <JobSeeker> ApplySorting(IQueryable <JobSeeker> query, JobSeekerFilterDto input)
        {
            var sortInput = input as ISortedResultRequest;

            if (sortInput != null)
            {
                if (sortInput.Sorting.IsNotNullOrEmpty())
                {
                    return(query.OrderBy(sortInput.Sorting));
                }
            }

            if (input is ILimitedResultRequest)
            {
                return(query.OrderByDescending(e => e.Id));
            }

            return(query);
        }