Beispiel #1
0
        private async Task <DataAboutRealEstatesForClientView> PreparedDataAboutRealEstates(ChoosenSearchParametrsForClientView choosenSearchParameters)
        {
            ChoosenSearchParametersForClientDTO choosenSearchParametersDTO = _mapper.Map <ChoosenSearchParametrsForClientView, ChoosenSearchParametersForClientDTO>
                                                                                 (choosenSearchParameters);
            var users = await _identityService.GetUsers().ProjectTo <UserViewModel>(_mapper.ConfigurationProvider).ToListAsync();

            List <RealEstateForClientDTO> realEstatesDTO = await _clientService.FormRealEstates(choosenSearchParametersDTO)
                                                           .Skip((choosenSearchParameters.Page - 1) * _pageSize)
                                                           .Take(_pageSize)
                                                           .ToListAsync();

            List <RealEstateForClientView> realEstates =
                _mapper.Map <List <RealEstateForClientDTO>, List <RealEstateForClientView> >(realEstatesDTO);


            DataAboutRealEstatesForClientView dataForRealtor = new DataAboutRealEstatesForClientView
            {
                ChoosenSearchParametersForRealtor = choosenSearchParameters,
                RealEstates      = realEstates,
                SearchParameters = _mapper.Map <DataForSearchParametersClientDTO, DataForSearchParametersClientView>(await _clientService.InitiateSearchParameters()),
                PagingInfo       = new PagingInfoView
                {
                    CurrentPage  = choosenSearchParameters.Page,
                    ItemsPerPage = _pageSize,
                    TotalItems   = await _clientService.FormRealEstates(choosenSearchParametersDTO).CountAsync()
                }
            };

            return(dataForRealtor);
        }
Beispiel #2
0
        public IQueryable <RealEstateForClientDTO> FormRealEstates(ChoosenSearchParametersForClientDTO parameters)
        {
            IQueryable <RealEstateForClientDTO> realEstates =
                from realEstate in _filter.FilteredRealEstates(_realEstatesData.RealEstates(), parameters)
                join street in _realEstatesData.Streets() on realEstate.StreetId equals street.Id
                join district in _filter.FilteredDistricts(_realEstatesData.KievDistricts(), parameters) on street.CityDistrictId equals district.Id
                select new RealEstateForClientDTO
            {
                Id           = realEstate.Id,
                Building     = realEstate.Building,
                Floor        = realEstate.Floor,
                Height       = realEstate.Height,
                Area         = realEstate.Area,
                Price        = realEstate.Price,
                RoomNumber   = realEstate.RoomNumber,
                CreationDate = realEstate.CreationDate,
                Description  = realEstate.Description,
                RealtorId    = realEstate.RealtorId,
                StreetName   = street.Name,
                DistrictName = district.Name,
                Image        = realEstate.Image,
                DistrictId   = district.Id,
                StreetId     = street.Id
            };

            return(_realeEstateSort.Sort(parameters.SortOrder)(realEstates));
        }
Beispiel #3
0
        public IQueryable <CityDistrictDTO> FilteredDistricts(IQueryable <CityDistrictDTO> districts, ChoosenSearchParametersForClientDTO parameters)
        {
            var result = districts;

            if (parameters.DistrictId.HasValue)
            {
                result = result.Where(x => x.Id == parameters.DistrictId);
            }
            return(result);
        }
Beispiel #4
0
        public IQueryable <RealEstateDTO> FilteredRealEstates(IQueryable <RealEstateDTO> realEstates, ChoosenSearchParametersForClientDTO parameters)
        {
            var result = realEstates;

            if (parameters.RoomNumber.HasValue)
            {
                result = result.Where(x => x.RoomNumber == parameters.RoomNumber);
            }

            if (parameters.AreaFrom.HasValue)
            {
                result = result.Where(x => x.Area >= parameters.AreaFrom);
            }
            if (parameters.AreaTo.HasValue)
            {
                result = result.Where(x => x.Area <= parameters.AreaTo);
            }

            if (parameters.PriceFrom.HasValue)
            {
                result = result.Where(x => x.Price >= parameters.PriceFrom);
            }
            if (parameters.PriceTo.HasValue)
            {
                result = result.Where(x => x.Price <= parameters.PriceTo);
            }

            if (parameters.HeightFrom.HasValue)
            {
                result = result.Where(x => x.Height >= parameters.HeightFrom);
            }
            if (parameters.HeightTo.HasValue)
            {
                result = result.Where(x => x.Height <= parameters.HeightTo);
            }

            if (parameters.FloorFrom.HasValue)
            {
                result = result.Where(x => x.Floor >= parameters.FloorFrom);
            }
            if (parameters.FloorTo.HasValue)
            {
                result = result.Where(x => x.Floor <= parameters.FloorTo);
            }

            result = result.Where(x => !x.IsSold);
            return(result);
        }