public async Task <CommuneContactInfoDto> GetCommuneContactInfoAsync(PagingRequestDto pagingAndSortingRequestDto, int communeId) { var commune = await _unitOfWork.GetRepository <GECommune>() .GetAll() .Include(x => x.GEDistrict) .FirstOrDefaultAsync(x => x.Id == communeId); if (commune == null) { throw new BusinessException("Xã không tồn tại"); } //Tìm những liên hệ phụ trách xã/huyện/tỉnh var contacts = await _unitOfWork.GetRepository <ARContact>() .GetAllIncluding(x => x.ARContactReviews, x => x.ARContactForestCommuneGroups, x => x.ADCreatedUser) .Where(x => x.ARContactForestCommuneGroups.Any(y => y.FK_GECommuneID == communeId || (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)) && x.ARContactStatus != ContactStatus.HuyBo) .MakeQueryToDatabaseAsync(); var forestPlotFromDb = await _unitOfWork.GetRepository <ICForestPlot>() .GetAllIncluding(x => x.GEPeoplesCommittee) .Include(x => x.GEForestProtectionDepartment) .ThenInclude(x => x.GEStateProvince) .Include(x => x.GEForestProtectionDepartment) .ThenInclude(x => x.GEDistrict) .FirstOrDefaultAsync(x => x.FK_GECommuneID == communeId); return(new CommuneContactInfoDto { Contacts = contacts.Select(x => x.ToShortContactDto()) .OrderByDescending(x => x.AverageRating) .ToPagedResult(pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize, x => x), UBND = forestPlotFromDb?.GEPeoplesCommittee.ToDictionaryItemDto(), ForestProtectionDepartment = forestPlotFromDb?.GEForestProtectionDepartment.ToForestProtectionDepartmentDto() }); }
public async Task <PagingResultDto <IEnumerable <Account> > > GetMembers( [FromQuery] PagingRequestDto <Account> pagingRequestDto) { return(await CreateServiceAsync <IGetAccountsSvc, PagingRequestDto <Account>, PagingResultDto <IEnumerable <Account> > >( _getAccountsSvc, pagingRequestDto)); }
public IActionResult GetProductCustomViews(PagingRequestDto request) { try { return(Ok(_productService.GetProductCustomViews(request))); } catch (Exception) { return(NotFound()); } }
public PagingDto <ProductDto> GetAvailableProducts(PagingRequestDto request) { var data = _unitOfWork.ProductRepository.GetRange(request.PageSize * request.PageNumber, request.PageSize, p => p.IsAvailable); return(new PagingDto <ProductDto> { Results = _mapper.Map <IEnumerable <ProductDto> >(data), PageNumber = request.PageNumber, PageSize = request.PageSize, TotalRecords = _unitOfWork.ProductRepository.Count(p => p.IsAvailable) }); }
public async Task <IPagedResultDto <ReviewItemDto> > GetContactReviewsAsync(PagingRequestDto pagingRequestDto, FilterContactReviewsDto filter) { return(await _unitOfWork.GetRepository <ARContactReview>() .GetAllIncluding(x => x.ADUser, x => x.ARContact) .SearchByFields( filter.SearchTerm, x => x.ARContact.ARContactName ) .WhereIf(filter.ContactStateProvinceId > 0, x => x.ARContact.FK_GEStateProvinceID == filter.ContactStateProvinceId) .WhereIf(filter.ContactDistrictId > 0, x => x.ARContact.FK_GEDistrictID == filter.ContactDistrictId) .WhereIf(filter.ContactCommuneId > 0, x => x.ARContact.FK_GECommuneID == filter.ContactCommuneId) .WhereIf(filter.Rating.HasValue, x => x.ARContactReviewRating == filter.Rating) .OrderByDescending(x => x.ARContactReviewDate) .GetPagedResultAsync(pagingRequestDto.Page, pagingRequestDto.PageSize, x => x.ToContactReviewDto())); }
public PagingDto <ProductCustomViewDto> GetProductCustomViews(PagingRequestDto request) { var data = _unitOfWork.ProductRepository.GetAllQuery().Select(p => new ProductCustomViewDto { CategoryCount = p.ProductCategories.Count, DeliveryDate = p.DeliveryDateTime.ToString("MM.dd.yyyy"), IsAVailable = p.IsAvailable ? "Available" : "Not available", Price = $"{p.Price:C}", ProductDescription = $"({p.Code}) {p.Description}", Type = $"({p.Unit.Code}) {p.Unit.Description}", Unit = $"({p.Unit.Code}) {p.Unit.Description}" }).Skip(request.PageSize * request.PageNumber).Take(request.PageSize).ToList(); return(new PagingDto <ProductCustomViewDto> { Results = data, PageNumber = request.PageNumber, PageSize = request.PageSize, TotalRecords = _unitOfWork.ProductRepository.Count() }); }
public async Task <IPagedResultDto <StateProvinceDto> > FilterStateProvincesAsynnc(PagingRequestDto pagingRequestDto, FilterStateProvinceDto filterDto) { return(await _unitOfWork.GetRepository <GEStateProvince>() .GetAll() .SearchByFields(filterDto.SearchTerm, x => x.GEStateProvinceName) .WhereIf(filterDto.IsHidden.HasValue, x => x.GEStateProvinceIsHidden.GetValueOrDefault() == filterDto.IsHidden.GetValueOrDefault()) .OrderBy(x => x.GEStateProvinceName) .GetPagedResultAsync( pagingRequestDto.Page, pagingRequestDto.PageSize, x => new StateProvinceDto { IsHidden = x.GEStateProvinceIsHidden.GetValueOrDefault(), Code = x.GECountryCode, Id = x.Id, Name = x.GEStateProvinceName })); }
public async Task <IPagedResultDto <ReviewItemDto> > GetAdminReviewsOfContactAsync(PagingRequestDto pagingRequestDto, int contactId) { return(await _unitOfWork.GetRepository <ARContactReview>() .GetAllIncluding(x => x.ADUser, x => x.ARContact) .Where(x => x.FK_ARContactID == contactId) .OrderByDescending(x => x.ARContactReviewDate) .GetPagedResultAsync(pagingRequestDto.Page, pagingRequestDto.PageSize, x => x.ToContactReviewDto())); }
public async Task <IPagedResultDto <ReviewItemDto> > GetReviewsOfContactAsync(PagingRequestDto pagingRequestDto, int contactId) { var extraData = new ExtraDataReviewsDto { ReviewCount = await _unitOfWork.GetRepository <ARContactReview>() .GetAll() .Where(x => x.FK_ARContactID == contactId) .CountAsync(), IsUserReview = await _unitOfWork.GetRepository <ARContactReview>() .GetAll() .AnyAsync(x => x.FK_ReviewUserID == _bysSession.GetUserId() && x.FK_ARContactID == contactId) }; return(await _unitOfWork.GetRepository <ARContactReview>() .GetAllIncluding(x => x.ADUser, x => x.ARContact) .Where(x => x.FK_ARContactID == contactId) .Where(x => !x.ARContactReviewIsHide.GetValueOrDefault()) .OrderByDescending(x => x.ARContactReviewDate) .GetPagedResultAsync(pagingRequestDto.Page, pagingRequestDto.PageSize, x => x.ToContactReviewDto(), extraData)); }
public async Task <IPagedResultDto <ReviewItemDto> > GetAdminReviewsOfForestPlotAsync(PagingRequestDto pagingRequestDto, int forestPlotId, int actorId) { return(await _unitOfWork.GetRepository <APActorReview>() .GetAllIncluding(x => x.APActor, x => x.ADUser, x => x.ICForestPlot) .IncludesForToForestPlot(x => x.ICForestPlot) .Where(x => x.FK_ICForestPlotID == forestPlotId) .Where(x => x.FK_APActorID == actorId) .OrderByDescending(x => x.APActorReviewDate) .GetPagedResultAsync(pagingRequestDto.Page, pagingRequestDto.PageSize, x => x.ToReviewItemDto())); }
public async Task <IPagedResultDto <ReviewItemDto> > GetReviewsOfForestPlotAsync(PagingRequestDto pagingRequestDto, int forestPlotId, int actorId) { var extraData = new ExtraDataReviewsDto { IsUserReview = await _unitOfWork.GetRepository <APActorReview>() .GetAll() .AnyAsync(x => x.FK_ReviewUserID == _bysSession.GetUserId() && x.FK_ICForestPlotID == forestPlotId) }; return(await _unitOfWork.GetRepository <APActorReview>() .GetAllIncluding(x => x.APActor, x => x.ADUser, x => x.ICForestPlot) .IncludesForToForestPlot(x => x.ICForestPlot) .Where(x => x.FK_ICForestPlotID == forestPlotId && x.APActorReviewIsHide == false && x.FK_APActorID == actorId) .OrderByDescending(x => x.APActorReviewDate) .GetPagedResultAsync(pagingRequestDto.Page, pagingRequestDto.PageSize, x => x.ToReviewItemDto(), extraData)); }
public async Task <IPagedResultDto <ShortContactDto> > GetContactsOfCommuneAsync(PagingRequestDto pagingAndSortingRequestDto, FilterContactsOfCommuneDto filter) { var commune = await _unitOfWork.GetRepository <GECommune>() .GetAll() .Include(x => x.GEDistrict) .FirstOrDefaultAsync(x => x.Id == filter.CommuneId); if (commune == null) { throw new BusinessException("Xã không tồn tại"); } var statusCount = await _unitOfWork.GetRepository <ARContactForestCommuneGroup>() .GetAllIncluding(x => x.ARContact, x => x.GEDistrict, x => x.GECommune, x => x.GEStateProvince) .Where(x => x.FK_GECommuneID == filter.CommuneId || (x.FK_GECommuneID == null && x.FK_GEDistrictID == commune.FK_GEDistrictID) || (x.FK_GECommuneID == null && x.FK_GEDistrictID == null && x.FK_GEStateProvinceID == commune.GEDistrict.FK_GEStateProvinceID)) .ToArrayAsync(); ContactStatusCountDto extraData; if (statusCount.IsNullOrEmpty()) { var communeFromDb = _unitOfWork.GetRepository <GECommune>() .GetAll() .Include(x => x.GEDistrict) .ThenInclude(x => x.GEStateProvince) .FirstOrDefault(x => x.Id == filter.CommuneId); extraData = new ContactStatusCountDto { Total = 0, ChuaDuyet = 0, DaDuyet = 0, HuyBo = 0, DangXacMinh = 0, StateProvince = communeFromDb.GEDistrict.GEStateProvince.ToDictionaryItemDto(), District = communeFromDb.GEDistrict.ToDictionaryItemDto(), Commune = communeFromDb.ToDictionaryItemDto() }; } else { extraData = statusCount.ToContactStatusCountDto(); } var contacts = await _unitOfWork.GetRepository <ARContact>() .GetAllIncluding(x => x.ARContactReviews, x => x.ARContactForestCommuneGroups, x => x.ADCreatedUser) .Where(x => x.ARContactForestCommuneGroups.Any(y => y.FK_GECommuneID == filter.CommuneId || (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))) .SearchByFields(filter.SearchTerm, x => x.ARContactContributor, x => x.ARContactEmail, x => x.ARContactName) .WhereIf(!filter.ContactStatus.IsNullOrEmpty(), x => x.ARContactStatus == filter.ContactStatus) .MakeQueryToDatabaseAsync(); return(contacts .Select(x => x.ToShortContactDto()) .OrderByDescending(x => x.AverageRating) .ToPagedResult(pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize, extraData)); }
public async Task <IPagedResultDto <SummaryCommuneContactDto> > GetSummaryCommuneContactAsync(PagingRequestDto pagingAndSortingRequestDto, LocationFilterDto locationFilter) { return(await _unitOfWork.GetRepository <GECommune>() .GetAllIncluding(x => x.GEDistrict, x => x.ARContactForestCommuneGroups) .Include(x => x.GEDistrict) .ThenInclude(x => x.ARContactForestCommuneGroups) .Include(x => x.GEDistrict) .ThenInclude(x => x.GEStateProvince) .ThenInclude(x => x.ARContactForestCommuneGroups) .Include(x => x.ARContactForestCommuneGroups) .ThenInclude(x => x.ARContact) .WhereIf(locationFilter.StateProvinceId > 0, x => x.GEDistrict.FK_GEStateProvinceID == locationFilter.StateProvinceId) .WhereIf(locationFilter.DistrictId > 0, x => x.FK_GEDistrictID == locationFilter.DistrictId) .WhereIf(locationFilter.CommuneId > 0, x => x.Id == locationFilter.CommuneId) .GetPagedResultAsync( pagingAndSortingRequestDto.Page, pagingAndSortingRequestDto.PageSize, x => x.ToSummaryCommuneContactDto())); }