示例#1
0
        private FeelSearchQueryResult AdvanceSearch(FeelSearchQuery query)
        {
            var siteEvents = _eventSiteIdMappingRepository
                             .GetBySiteId(query.SiteId)
                             .OrderBy(o => o.SortOrder).ToList();

            List <Contracts.DataModels.Event> searchEvents = new List <Contracts.DataModels.Event>();

            if (query.PlaceAltIds != null && query.PlaceAltIds.Count() > 0)
            {
                searchEvents = _eventRepository.GetEventsByAltIds(query.PlaceAltIds)
                               .ToList();
            }
            else
            {
                searchEvents = _eventRepository.GetFeelEventsBySearchString(query.Name, query.SiteId)
                               .ToList();
            }

            var eventMapping          = searchEvents.ToDictionary(e => e.Id);
            var eventIds              = eventMapping.Keys;
            var eventCategoryMappings = _eventCategoryMappingRepository.GetByEventIds(eventIds).Where(ed => ed.IsEnabled == true);
            var allEventDetails       = _eventDetailRepository.GetByEventIds(eventIds).Where(ed => ed.IsEnabled == true);
            var allEventRatings       = _ratingRepository.GetByEventIds(eventIds);
            var venueMapping          = _venueRepository.GetByVenueIds(allEventDetails.Select(ed => ed.VenueId).Distinct())
                                        .ToDictionary(v => v.Id);
            var eventDetailsMapping = allEventDetails.GroupBy(ed => ed.EventId)
                                      .ToDictionary(g => g.Key, g => g.ToList());
            var eventCategoryMapping = eventCategoryMappings.GroupBy(ed => ed.EventId)
                                       .ToDictionary(g => g.Key, g => g.ToList());
            var eventRatingMapping = allEventRatings.GroupBy(ed => ed.EventId)
                                     .ToDictionary(g => g.Key, g => g.ToList());
            var cityIds     = venueMapping.Values.Select(s => s.CityId).Distinct();
            var cityMapping = _cityRepository.GetByCityIds(cityIds)
                              .ToDictionary(c => c.Id);
            var stateId      = cityMapping.Values.Select(c => c.StateId).Distinct();
            var stateMapping = _stateRepository.GetByStateIds(stateId)
                               .ToDictionary(s => s.Id);
            var countryIdList  = stateMapping.Values.Select(s => s.CountryId).Distinct();
            var countryMapping = _countryRepository.GetByCountryIds(countryIdList)
                                 .ToDictionary(c => c.Id);
            var eventsBySortOrder = new List <FIL.Contracts.DataModels.Event>();

            foreach (var item in siteEvents)
            {
                var events = searchEvents.FirstOrDefault(w => w.Id == item.EventId);
                if (events != null)
                {
                    eventsBySortOrder.Add(AutoMapper.Mapper.Map <FIL.Contracts.DataModels.Event>(events));
                }
            }
            var CategoryEventData = eventsBySortOrder.Select(ce =>
            {
                try
                {
                    var eventObj         = eventMapping[ce.Id];
                    var eventDetails     = eventDetailsMapping[ce.Id];
                    var eventCategoryMap = eventCategoryMapping[ce.Id];
                    List <FIL.Contracts.DataModels.Rating> eventRatings;
                    if (eventRatingMapping.ContainsKey(ce.Id))
                    {
                        eventRatings = eventRatingMapping[ce.Id];
                    }
                    else
                    {
                        eventRatings = null;
                    }
                    var eventDetailIdList           = eventDetails.Select(s => s.Id).Distinct().ToList();
                    var venues                      = eventDetails.Select(s => s.VenueId).Distinct().Select(v => venueMapping[v]);
                    var cities                      = venues.Select(s => s.CityId).Distinct().Select(c => cityMapping[c]);
                    var states                      = cities.Select(s => s.StateId).Distinct().Select(s => stateMapping[s]);
                    var countries                   = states.Select(s => s.CountryId).Distinct().Select(c => countryMapping[c]);
                    var eventTicketAttributeMapping = new List <Contracts.DataModels.EventTicketAttribute>
                    {
                        _eventTicketAttributeRepository.GetMaxPriceByEventDetailId(eventDetailIdList),
                        _eventTicketAttributeRepository.GetMinPriceByEventDetailId(eventDetailIdList)
                    };
                    var currencyMapping            = _currencyTypeRepository.GetByCurrencyId(eventTicketAttributeMapping.First().CurrencyId);
                    List <string> eventCatMappings = new List <string>();

                    foreach (var eventCat in eventCategoryMap)
                    {
                        var eventCategoryDataModel = _eventCategoryRepository.Get(eventCat.EventCategoryId);
                        var eventCategoryModel     = AutoMapper.Mapper.Map <Contracts.Models.EventCategory>(eventCategoryDataModel);
                        eventCatMappings.Add(eventCategoryModel.DisplayName);
                    }
                    return(new CategoryEventContainer
                    {
                        CategoryEvent = Mapper.Map <Contracts.Models.CategoryEvent>(ce),
                        EventType = eventObj.EventTypeId.ToString(),
                        EventCategory = eventObj.EventCategoryId.ToString(),
                        City = Mapper.Map <IEnumerable <City> >(cities),
                        State = Mapper.Map <IEnumerable <State> >(states),
                        Country = Mapper.Map <IEnumerable <Country> >(countries),
                        Event = Mapper.Map <Event>(eventObj),
                        EventDetail = Mapper.Map <IEnumerable <EventDetail> >(eventDetails),
                        Rating = Mapper.Map <IEnumerable <Rating> >(eventRatings),
                        CurrencyType = Mapper.Map <CurrencyType>(currencyMapping),
                        Venue = Mapper.Map <IEnumerable <Venue> >(venues),
                        EventTicketAttribute = Mapper.Map <IEnumerable <EventTicketAttribute> >(eventTicketAttributeMapping),
                        EventCategories = eventCatMappings
                    });
                }
                catch (Exception e)
                {
                    return(new CategoryEventContainer
                    {
                    });
                }
            });

            return(new FeelSearchQueryResult
            {
                FeelAdvanceSearchQueryResult = new FeelCategoryEventQueryResult
                {
                    CategoryEvents = CategoryEventData.ToList()
                }
            });
        }
示例#2
0
        public CategoryEventQueryResult Handle(CategoryEventQuery query)
        {
            var categoryEventsForSite = _eventRepository.GetByCategoryId(query.EventCategoryId).Where(e => e.IsEnabled).ToList();
            var eventMapping          = categoryEventsForSite.ToDictionary(e => e.Id);
            var eventIds        = eventMapping.Keys;
            var allEventDetails = _eventDetailRepository.GetByEventIds(eventIds).Where(ed => ed.IsEnabled).ToList();
            var venueMapping    = _venueRepository.GetByVenueIds(allEventDetails.Select(ed => ed.VenueId).Distinct())
                                  .ToDictionary(v => v.Id);
            var eventDetailsMapping = allEventDetails.GroupBy(ed => ed.EventId)
                                      .ToDictionary(g => g.Key, g => g.ToList());
            var cityIds     = venueMapping.Values.Select(s => s.CityId).Distinct();
            var cityMapping = _cityRepository.GetByCityIds(cityIds)
                              .ToDictionary(c => c.Id);
            var stateId      = cityMapping.Values.Select(c => c.StateId).Distinct();
            var stateMapping = _stateRepository.GetByStateIds(stateId)
                               .ToDictionary(s => s.Id);
            var countryIdList  = stateMapping.Values.Select(s => s.CountryId).Distinct();
            var countryMapping = _countryRepository.GetByCountryIds(countryIdList)
                                 .ToDictionary(c => c.Id);
            var currencyTypeList  = _currencyTypeRepository.GetAll();
            var CategoryEventData = categoryEventsForSite.Select(ce =>
            {
                var eventObj = eventMapping[ce.Id];
                if (eventDetailsMapping.ContainsKey(ce.Id))
                {
                    var eventDetails      = eventDetailsMapping[ce.Id];
                    var eventDetailIdList = eventDetails.Select(s => s.Id).Distinct();
                    var venues            = eventDetails.Select(s => s.VenueId).Distinct().Select(v => venueMapping[v]);
                    var cities            = venues.Select(s => s.CityId).Distinct().Select(c => cityMapping[c]);
                    var states            = cities.Select(s => s.StateId).Distinct().Select(s => stateMapping[s]);
                    var countries         = states.Select(s => s.CountryId).Distinct().Select(c => countryMapping[c]);
                    if (!eventDetailIdList.Any())
                    {
                        return(new CategoryEventContainer {
                        });
                    }
                    var eventTicketAttributeMapping = new List <Contracts.DataModels.EventTicketAttribute>
                    {
                        _eventTicketAttributeRepository.GetMaxPriceByEventDetailId(eventDetailIdList),
                        _eventTicketAttributeRepository.GetMinPriceByEventDetailId(eventDetailIdList)
                    };
                    if (eventTicketAttributeMapping.Any())
                    {
                        var currencyMapping = currencyTypeList.Where(s => s.Id == eventTicketAttributeMapping.FirstOrDefault().CurrencyId).FirstOrDefault();
                        return(new CategoryEventContainer
                        {
                            CategoryEvent = Mapper.Map <Contracts.Models.CategoryEvent>(ce),
                            EventType = eventObj.EventTypeId.ToString(),
                            City = Mapper.Map <IEnumerable <City> >(cities),
                            State = Mapper.Map <IEnumerable <State> >(states),
                            Country = Mapper.Map <IEnumerable <Country> >(countries),
                            Event = Mapper.Map <Event>(eventObj),
                            EventDetail = Mapper.Map <IEnumerable <EventDetail> >(eventDetails),
                            CurrencyType = Mapper.Map <CurrencyType>(currencyMapping),
                            Venue = Mapper.Map <IEnumerable <Venue> >(venues),
                            EventTicketAttribute = Mapper.Map <IEnumerable <EventTicketAttribute> >(eventTicketAttributeMapping),
                        });
                    }
                    else
                    {
                        return(new CategoryEventContainer {
                        });
                    }
                }
                else
                {
                    return(new CategoryEventContainer
                    {
                    });
                }
            });

            if (CategoryEventData.ToList() != null)
            {
                return(new CategoryEventQueryResult
                {
                    CategoryEvents = CategoryEventData.Where(s => s.Event != null).ToList()
                });
            }
            else
            {
                return(new CategoryEventQueryResult
                {
                });
            }
        }
示例#3
0
        public RecommendationQueryResult Handle(RecommendationQuery query)
        {
            var sessionResponseIA     = _initSession.GetSession().Result;
            RecommendationModel model = new RecommendationModel
            {
                ClientType    = "web_site",
                Count         = 4,
                SessionId     = sessionResponseIA.Result.SessionId,
                SitePageType  = "product_detail",
                siteProductId = query.Id,
            };
            var recommendations     = _getRecommendation.GetRecommendations(model).Result;
            var recomendationResult = AutoMapper.Mapper.Map <List <RecommendationItem> >(recommendations.Result.Data[0].Items);
            var recommendationIds   = recomendationResult.Select(e => e.SiteProductId);

            var siteEvents            = _eventSiteIdMappingRepository.GetBySiteId(query.SiteId).OrderBy(o => o.SortOrder);
            var categoryEvents        = _eventRepository.GetByCategoryId(query.EventCategoryId).Where(e => e.IsEnabled == true);
            var categoryEventsForSite = categoryEvents.Where(ce => recommendationIds.Any(se => se == (ce.Id)));
            var eventIds        = categoryEventsForSite.Select(ce => ce.Id);
            var eventMapping    = _eventRepository.GetByEventIds(eventIds).Where(e => e.IsEnabled == true).ToDictionary(e => e.Id);
            var allEventDetails = _eventDetailRepository.GetByEventIds(eventIds).Where(ed => ed.IsEnabled == true);
            var venueMapping    = _venueRepository.GetByVenueIds(allEventDetails.Select(ed => ed.VenueId).Distinct())
                                  .ToDictionary(v => v.Id);
            var eventDetailsMapping = allEventDetails.GroupBy(ed => ed.EventId)
                                      .ToDictionary(g => g.Key, g => g.ToList());
            var cityIds     = venueMapping.Values.Select(s => s.CityId).Distinct();
            var cityMapping = _cityRepository.GetByCityIds(cityIds)
                              .ToDictionary(c => c.Id);
            var stateId      = cityMapping.Values.Select(c => c.StateId).Distinct();
            var stateMapping = _stateRepository.GetByStateIds(stateId)
                               .ToDictionary(s => s.Id);
            var countryIdList  = stateMapping.Values.Select(s => s.CountryId).Distinct();
            var countryMapping = _countryRepository.GetByCountryIds(countryIdList)
                                 .ToDictionary(c => c.Id);
            var CategoryEventData = categoryEventsForSite.Select(ce =>
            {
                var eventObj                    = eventMapping[ce.Id];
                var eventDetails                = eventDetailsMapping[ce.Id];
                var eventDetailIdList           = eventDetails.Select(s => s.Id).Distinct();
                var venues                      = eventDetails.Select(s => s.VenueId).Distinct().Select(v => venueMapping[v]);
                var cities                      = venues.Select(s => s.CityId).Distinct().Select(c => cityMapping[c]);
                var states                      = cities.Select(s => s.StateId).Distinct().Select(s => stateMapping[s]);
                var countries                   = states.Select(s => s.CountryId).Distinct().Select(c => countryMapping[c]);
                var eventTicketAttributeMapping = new List <Contracts.DataModels.EventTicketAttribute>
                {
                    _eventTicketAttributeRepository.GetMaxPriceByEventDetailId(eventDetailIdList),
                    _eventTicketAttributeRepository.GetMinPriceByEventDetailId(eventDetailIdList)
                };
                var currencyMapping = _currencyTypeRepository.GetByCurrencyId(eventTicketAttributeMapping.First().CurrencyId);
                return(new CategoryEventContainer
                {
                    CategoryEvent = Mapper.Map <Contracts.Models.CategoryEvent>(ce),
                    EventType = eventObj.EventTypeId.ToString(),
                    City = Mapper.Map <IEnumerable <City> >(cities),
                    State = Mapper.Map <IEnumerable <State> >(states),
                    Country = Mapper.Map <IEnumerable <Country> >(countries),
                    Event = Mapper.Map <Event>(eventObj),
                    EventDetail = Mapper.Map <IEnumerable <EventDetail> >(eventDetails),
                    CurrencyType = Mapper.Map <CurrencyType>(currencyMapping),
                    Venue = Mapper.Map <IEnumerable <Venue> >(venues),
                    EventTicketAttribute = Mapper.Map <IEnumerable <EventTicketAttribute> >(eventTicketAttributeMapping),
                });
            });

            return(new RecommendationQueryResult
            {
                CategoryEvents = CategoryEventData.ToList()
            });
        }