public async Task <DataAboutRealEstatesForRealtorDTO> FormRealEstates(string userId, ChoosenSearchParametersForRealtorDTO parameters)
        {
            IQueryable <RealEstateForRealtorDTO> realEstates =
                from realEstate in _filter.FilteredRealEstates(_realEstatesData.RealEstates(), parameters, userId)
                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
                join user in _realEstatesData.Users()
                on userId equals user.Id

                select new RealEstateForRealtorDTO
            {
                Id           = realEstate.Id,
                Building     = realEstate.Building,
                Appartment   = realEstate.Appartment,
                Floor        = realEstate.Floor,
                Height       = realEstate.Height,
                Area         = realEstate.Area,
                Price        = realEstate.Price,
                RoomNumber   = realEstate.RoomNumber,
                CreationDate = realEstate.CreationDate,
                Description  = realEstate.Description,
                IsSold       = realEstate.IsSold,
                RealtorId    = realEstate.RealtorId,
                RealtorName  = user.Name,
                RealtorEmail = user.Email,
                StreetName   = street.Name,
                DistrictName = district.Name,
                IsOwner      = (userId == realEstate.RealtorId),
                Image        = realEstate.Image,
                DistrictId   = district.Id,
                StreetId     = street.Id
            };

            IQueryable <RealEstateForRealtorDTO> result = _realeEstateSort.Sort(parameters.SortOrder)(realEstates);



            DataAboutRealEstatesForRealtorDTO dataForRealtor = new DataAboutRealEstatesForRealtorDTO
            {
                ChoosenSearchParametersForRealtor = parameters,
                RealEstates      = await result.Skip((parameters.Page - 1) *_itemsOnPage).Take(_itemsOnPage).ToListAsync(),
                SearchParameters = await InitiateSearchParameters(),
                PagingInfo       = new PagingInfoDTO
                {
                    CurrentPage  = parameters.Page,
                    ItemsPerPage = _itemsOnPage,
                    TotalItems   = await result.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));
        }