Пример #1
0
        public async Task <RoomTypeStat> GetRoomTypeStats(Filter filter)
        {
            var result = await _cache.Get <RoomTypeStat, Filter>(filter, Prefix.RoomTypeStat);

            if (result != null)
            {
                return(result);
            }

            var listings = _listingRepository.Get(filter);

            var privateRooms = listings.Count(listing => listing.RoomType == "Private room");
            var entireHomes  = listings.Count(listing => listing.RoomType == "Entire home/apt");
            var sharedRooms  = listings.Count(listing => listing.RoomType == "Shared room");

            result = new RoomTypeStat
            {
                PrivateRooms = privateRooms,
                EntireHomes  = entireHomes,
                SharedRooms  = sharedRooms
            };

            _cache.Set(filter, result, Prefix.RoomTypeStat);
            return(result);
        }
Пример #2
0
        public IQueryable <CalendarItem> GetPriceHistory(Filter filter)
        {
            var query    = _db.CalendarItems;
            var listings = _listingRepository.Get(filter);
            var result   = listings.Join(_db.CalendarItems,
                                         listing => listing.Id,
                                         item => item.ListingId,
                                         (listing, item) => item);

            return(result);
        }