コード例 #1
0
ファイル: ActorService.cs プロジェクト: war-man/HawaDNS
 private IQueryable <APActor> GetFilterActorsQuery(FilterActorDto filter)
 {
     return(_unitOfWork.GetRepository <APActor>()
            .GetAllIncluding(x => x.GEStateProvince, x => x.GEDistrict, x => x.GECommune)
            .Include(x => x.APActorRoles)
            .ThenInclude(x => x.APRole)
            .SearchByFields(
                filter.SearchTerm,
                x => x.APActorIdentityCard,
                x => x.APActorName,
                x => x.APActorAcronymName,
                x => x.APActorEmail,
                x => x.APActorPhone)
            .WhereIf(filter.ActorRoleId.HasValue, x => x.APActorRoles.Any(y => y.FK_APRoleID == filter.ActorRoleId))
            //.WhereIf(filter.Status.IsNullOrWhiteSpace(), x => x.APActorStatus == filter.Status)
            .WhereIf(filter.StateProvinceID.HasValue, x => x.FK_GEStateProvinceID == filter.StateProvinceID)
            .WhereIf(filter.DistrictID.HasValue, x => x.FK_GEDistrictID == filter.DistrictID)
            .WhereIf(filter.CommuneID.HasValue, x => x.FK_GECommuneID == filter.CommuneID));
 }
コード例 #2
0
ファイル: ActorService.cs プロジェクト: war-man/HawaDNS
        public async Task <IPagedResultDto <ShortActorDto> > FilterForestPlotActorsAsync(PagingAndSortingRequestDto pagingAndSortingRequestDto, FilterActorDto filterDto)
        {
            var forestPlotIds = await _unitOfWork.GetRepository <ICForestPlot>()
                                .GetAll()
                                .SearchByFields(filterDto.SearchTerm, x => x.APActor.APActorName)
                                .Where(x => x.FK_APActorID == filterDto.ActorId)
                                .Where(x => x.APActor != null)
                                .WhereIf(filterDto.StateProvinceID > 0, x => x.FK_GEStateProvinceID == filterDto.StateProvinceID)
                                .WhereIf(filterDto.DistrictID > 0, x => x.FK_GEDistrictID == filterDto.DistrictID)
                                .WhereIf(filterDto.CommuneID > 0, x => x.FK_GECommuneID == filterDto.CommuneID)
                                .WhereIf(filterDto.SubCompartmentId > 0, x => x.FK_GESubCompartmentID == filterDto.SubCompartmentId)
                                .WhereIf(filterDto.CompartmentId > 0, x => x.FK_GECompartmentID == filterDto.CompartmentId)
                                .WhereIf(!filterDto.PlotCode.IsNullOrEmpty(), x => x.GEPlotCode == filterDto.PlotCode)
                                .OrderByDescending(x => x.ICForestPlotLatestReviewDate)
                                .Select(x => x.Id)
                                .GetPagedResultAsync(pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize);

            var forestPlots = await _unitOfWork.GetRepository <ICForestPlot>()
                              .GetAllIncluding(
                x => x.APActorReviews,
                x => x.GECommunes,
                x => x.GEDistrict,
                x => x.GEStateProvince,
                x => x.GESubCompartment,
                x => x.GECompartment,
                x => x.APActor,
                x => x.APActor.APActorType)
                              .Where(x => forestPlotIds.Items.Contains(x.Id))
                              .OrderByDescending(x => x.ICForestPlotLatestReviewDate)
                              .Select(x => x.ToShortActorDto())
                              .ToArrayAsync();

            return(new PagedResultDto <ShortActorDto>
            {
                PageSize = forestPlotIds.PageSize,
                Items = forestPlots,
                PageIndex = forestPlotIds.PageIndex,
                TotalCount = forestPlotIds.TotalCount,
                TotalPages = forestPlotIds.TotalPages
            });
        }
コード例 #3
0
ファイル: ActorService.cs プロジェクト: war-man/HawaDNS
        public async Task <IPagedResultDto <ActorDto> > FilterActorsAsync(PagingAndSortingRequestDto pagingAndSortingRequestDto, FilterActorDto filter)
        {
            var query = GetFilterActorsQuery(filter);

            return(await query
                   .ApplySorting(pagingAndSortingRequestDto)
                   .GetPagedResultAsync(pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize, x => x.ToActorDto()));
        }