Esempio n. 1
0
 public Task <IPagedResultDto <TreeSpecDto> > FilterTreeSpecsAsync(PagingAndSortingRequestDto pagingAndSortingRequestDto, int treeSpecGroupId)
 {
     return(_unitOfWork.GetRepository <ICTreeSpec>()
            .GetAll()
            .Where(x => x.FK_ICTreeSpecGroupID == treeSpecGroupId)
            .GetPagedResultAsync(pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize, x => x.ToTreeSpecDto()));
 }
Esempio n. 2
0
        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()));
        }
Esempio n. 3
0
 public async Task <IPagedResultDto <TreeSpecDto> > FilterTreeSpecsAsync(PagingAndSortingRequestDto pagingAndSortingRequest, string searchTerm)
 {
     return(await _unitOfWork.GetRepository <ICTreeSpec>()
            .GetAll()
            .SearchByFields(searchTerm, x => x.ICTreeSpecName)
            .OrderBy(x => x.Id)
            .GetPagedResultAsync(pagingAndSortingRequest.Page, pagingAndSortingRequest.PageSize, x => x.ToTreeSpecDto()));
 }
Esempio n. 4
0
 public async Task <IPagedResultDto <FeedbackDto> > FilterFeedbacksAsync(PagingAndSortingRequestDto pagingAndSortingRequestDto, FilterFeedbacksDto filter)
 {
     return(await _unitOfWork.GetRepository <ADFeedback>()
            .GetAllIncluding(x => x.ADFeedbackUser)
            .WhereIf(filter.IsLike.HasValue, x => x.ADFeedbackIsLike == filter.IsLike)
            .OrderByDescending(x => x.AACreatedDate)
            .GetPagedResultAsync(
                pagingAndSortingRequestDto.Page,
                pagingAndSortingRequestDto.PageSize,
                x => new FeedbackDto
     {
         Id = x.Id,
         IsLike = x.ADFeedbackIsLike,
         Date = x.AACreatedDate.ToSecondsTimestamp(),
         Content = x.ADFeedbackContent,
         User = x.ADFeedbackUser.ToShortUserDto(),
     }));
 }
Esempio n. 5
0
        public async Task <IPagedResultDto <ForestPlotDto> > FilterForestPlotsAsync(PagingAndSortingRequestDto pagingAndSortingRequestDto, FilterForestPlotDto filter)
        {
            var treespecIdsByGroup = await _unitOfWork.GetRepository <ICTreeSpecGroupItem>()
                                     .GetAll()
                                     .Where(x => x.FK_ICTreeSpecGroupID == filter.TreeSpecGroupID)
                                     .Select(x => x.FK_ICTreeSpecID)
                                     .MakeQueryToDatabaseAsync();

            return(await _unitOfWork.GetRepository <ICPlot>()
                   .GetAll()
                   .Include(x => x.ICTreeSpecGroup)
                   .Include(x => x.ICTreeSpec)
                   .Include(x => x.GECommune)
                   .ThenInclude(x => x.GEDistrict)
                   .ThenInclude(x => x.GEStateProvince)
                   .WhereIf(filter.StateProvinceID > 0, x => x.GECommune.GEDistrict.FK_GEStateProvinceID == filter.StateProvinceID)
                   .WhereIf(filter.DistrictID > 0, x => x.GECommune.FK_GEDistrictID == filter.DistrictID)
                   .WhereIf(filter.CommuneID > 0, x => x.FK_GECommuneID == filter.CommuneID)
                   .WhereIf(filter.TreeSpecID > 0, x => x.FK_ICTreeSpecID == filter.TreeSpecID)
                   .WhereIf(filter.TreeSpecGroupID > 0, x => treespecIdsByGroup.Contains(x.FK_ICTreeSpecID.GetValueOrDefault()))
                   .ApplySorting(pagingAndSortingRequestDto)
                   .GetPagedResultAsync(pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize, x => x.ToForestPlotDto()));
        }
Esempio n. 6
0
 public Task <IPagedResultDto <TreeSpecGroupDto> > FilterTreeSpecGroupsAsync(PagingAndSortingRequestDto pagingAndSortingRequestDto)
 {
     return(_unitOfWork.GetRepository <ICTreeSpecGroup>()
            .GetAll()
            .GetPagedResultAsync(pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize, x => x.ToTreeSpecGroupDto()));
 }
Esempio n. 7
0
        public async Task <IPagedResultDto <ForestPlotDetailDto> > FilterForestPlotDetailsAsync(PagingAndSortingRequestDto pagingAndSortingRequestDto, FilterForestPlotDetailDto filter)
        {
            var plot = await _unitOfWork.GetRepository <ICPlot>()
                       .GetAll()
                       .Include(x => x.ICTreeSpecGroup)
                       .Include(x => x.ICTreeSpec)
                       .Include(x => x.GECommune)
                       .ThenInclude(x => x.GEDistrict)
                       .ThenInclude(x => x.GEStateProvince)
                       .FirstOrDefaultAsync(x => x.FK_GECommuneID == filter.CommuneID && x.FK_ICTreeSpecID == filter.TreeSpecID);

            var query = GetFilterForestPlotsQuery(filter);

            return(await query.OrderBy(x => x.Id)
                   .ApplySorting(pagingAndSortingRequestDto)
                   .GetPagedResultAsync(pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize, x => x.ToForestPlotDetailDto(), plot.ToForestPlotDto()));
        }
Esempio n. 8
0
        public async Task <IPagedResultDto <ForestPlotDetailHistoryDto> > FilterForestPlotHistoryDetailsAsync(PagingAndSortingRequestDto pagingAndSortingRequestDto, FilterForestPlotHistoryDetailDto filter)
        {
            var query = GetFilterForestPlotHistorysQuery(filter);

            return(await query.OrderBy(x => x.Id)
                   .ApplySorting(pagingAndSortingRequestDto)
                   .GetPagedResultAsync(pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize, x => x.ToForestPlotHistoryDto()));
        }
Esempio n. 9
0
 public async Task <IPagedResultDto <TreeSpecGroupDto> > FilterTreeSpecGroupsAsync(PagingAndSortingRequestDto pagingAndSorting, string searchTerm)
 {
     return(await _unitOfWork.GetRepository <ICTreeSpecGroup>()
            .GetAllIncluding(x => x.ICTreeSpecGroupItems)
            .Include(x => x.ICTreeSpecGroupItems)
            .ThenInclude(x => x.ICTreeSpec)
            .SearchByFields(searchTerm, x => x.ICTreeSpecGroupName, x => x.ICTreeSpecGroupDesc)
            .OrderBy(x => x.ICTreeSpecGroupName)
            .GetPagedResultAsync(pagingAndSorting.Page, pagingAndSorting.PageSize, x => x.ToTreeSpecGroupDto()));
 }
Esempio n. 10
0
        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
            });
        }
Esempio n. 11
0
 public async Task <IPagedResultDto <NotificationDto> > FilterNotificationsAsync(FilterNotificationDto dto, PagingAndSortingRequestDto pagingAndSortingRequestDto)
 {
     return(await _unitOfWork.GetRepository <ARNotification>()
            .GetAllIncluding(x => x.ADUser)
            .WhereIf(dto.NotificationRead.HasValue, x => x.ARNotificationRead == dto.NotificationRead)
            .WhereIf(!dto.NotificationSystemType.IsNullOrWhiteSpace(), x => x.ARNotificationSystemTypeCombo == dto.NotificationSystemType)
            .WhereIf(dto.StartDate.HasValue, x => x.AACreatedDate.Date >= dto.StartDate.FromUnixTimeStamp().GetValueOrDefault().Date)
            .WhereIf(dto.EndDate.HasValue, x => x.AACreatedDate.Date <= dto.EndDate.FromUnixTimeStamp().GetValueOrDefault().Date)
            .OrderByDescending(x => x.AACreatedDate)
            .GetPagedResultAsync(pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize, x => x.ToNotificationDto()));
 }
Esempio n. 12
0
        public async Task <IPagedResultDto <ShortContactDto> > FilterForestContactsAsync(PagingAndSortingRequestDto pagingAndSortingRequestDto, FilterContactsDto filter)
        {
            GECommune commune = null;

            if (filter.ContactCommuneId > 0)
            {
                commune = await _unitOfWork.GetRepository <GECommune>()
                          .GetAll()
                          .Include(x => x.GEDistrict)
                          .FirstOrDefaultAsync(x => x.Id == filter.ContactCommuneId);
            }

            GEDistrict district = null;

            if (filter.ContactDistrictId > 0)
            {
                district = await _unitOfWork.GetRepository <GEDistrict>()
                           .GetAll()
                           .Include(x => x.GEStateProvince)
                           .FirstOrDefaultAsync(x => x.Id == filter.ContactDistrictId);
            }

            return(await _unitOfWork.GetRepository <ARContact>()
                   .GetAllIncluding(x => x.ARContactReviews)
                   .SearchByFields(filter.SearchTerm, x => x.ARContactName, x => x.ARContactAcronymName, x => x.ARContactContributor, x => x.ARContactUserContact)
                   .WhereIf(filter.ContactStateProvinceId > 0, x => x.ARContactForestCommuneGroups.Any(y => y.FK_GEStateProvinceID == filter.ContactStateProvinceId))
                   .WhereIf(district != null, x => x.ARContactForestCommuneGroups.Any(y => y.FK_GEDistrictID == filter.ContactDistrictId || (y.FK_GEDistrictID == null && y.FK_GEStateProvinceID == district.FK_GEStateProvinceID)))
                   .WhereIf(commune != null, x => x.ARContactForestCommuneGroups.Any(y => y.FK_GECommuneID == filter.ContactCommuneId || (y.FK_GECommuneID == null && y.FK_GEDistrictID == commune.FK_GEDistrictID) || (y.FK_GECommuneID == null && y.FK_GEDistrictID == null && y.FK_GEStateProvinceID == commune.GEDistrict.FK_GEStateProvinceID)))
                   .OrderByDescending(x => x.ARContactReviews.Max(y => y.ARContactReviewDate))

                   //.WhereIf(locationFilter.Rating.HasValue, x => x.ARContactReviewRating == locationFilter.Rating)
                   .ApplySorting(pagingAndSortingRequestDto)
                   .GetPagedResultAsync(
                       pagingAndSortingRequestDto.Page,
                       pagingAndSortingRequestDto.PageSize,
                       x => x.ToShortContactDto()));
        }