public static DictionaryItemDto ToDictionaryItemDto(this GECommune value)
 {
     return(value == null
         ? null
         : new DictionaryItemDto
     {
         Key = value.Id.ToString(),
         Code = value.GECommuneCode,
         Text = value.GECommuneName
     });
 }
示例#2
0
 public static SummaryCommuneContactDto ToSummaryCommuneContactDto(this GECommune entity)
 {
     return(entity == null
         ? null
         : new SummaryCommuneContactDto
     {
         StateProvince = entity.GEDistrict?.GEStateProvince.ToDictionaryItemDto(),
         Commune = entity.ToDictionaryItemDto(),
         District = entity.GEDistrict.ToDictionaryItemDto(),
         ReviewCount = entity.ARContactForestCommuneGroups.Count + entity.GEDistrict.ARContactForestCommuneGroups.Count(x => x.FK_GECommuneID == null) + entity.GEDistrict.GEStateProvince.ARContactForestCommuneGroups.Count(x => x.FK_GECommuneID == null && x.FK_GEDistrictID == null),
         NotConfirmStatusCount = entity.ARContactForestCommuneGroups.Count(x => x.ARContact?.ARContactStatus == ContactStatus.ChuaDuyet) + entity.GEDistrict.ARContactForestCommuneGroups.Count(x => x.ARContact?.ARContactStatus == ContactStatus.ChuaDuyet && x.FK_GECommuneID == null) + entity.GEDistrict.GEStateProvince.ARContactForestCommuneGroups.Count(x => x.ARContact?.ARContactStatus == ContactStatus.ChuaDuyet && x.FK_GECommuneID == null && x.FK_GEDistrictID == null),
         PendingStatusCount = entity.ARContactForestCommuneGroups.Count(x => x.ARContact?.ARContactStatus == ContactStatus.DangXacMinh) + entity.GEDistrict.ARContactForestCommuneGroups.Count(x => x.ARContact?.ARContactStatus == ContactStatus.DangXacMinh && x.FK_GECommuneID == null) + entity.GEDistrict.GEStateProvince.ARContactForestCommuneGroups.Count(x => x.ARContact?.ARContactStatus == ContactStatus.DangXacMinh && x.FK_GECommuneID == null && x.FK_GEDistrictID == null)
     });
 }
示例#3
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()));
        }