Пример #1
0
        public EventsCategoryFeelQueryResult Handle(EventsCategoryFeelQuery query)
        {
            var eventResult = _eventCategoryRepository.GetAll();
            List <EventCategoryData> categorydataList = new List <EventCategoryData>();

            foreach (var item in eventResult)
            {
                var description = new EventCategoryData();
                description.CategoryId        = item.EventCategoryId;
                description.DisplayName       = item.DisplayName;
                description.IsFeel            = item.IsFeel;
                description.IsHomePage        = item.IsHomePage;
                description.Order             = item.Order;
                description.Slug              = item.Slug;
                description.Value             = item.Id;
                description.MasterEventTypeId = item.MasterEventTypeId;
                if (description.IsFeel)
                {
                    categorydataList.Add(description);
                }
            }
            return(new EventsCategoryFeelQueryResult()
            {
                EventCategoryFeel = categorydataList
            });
        }
Пример #2
0
        public FeelUserJourneyQueryResult Handle(FeelUserJourneyQuery query)
        {
            try
            {
                var isCategoryLevel     = query.CategoryId != 0;
                var isSubcategoryLevel  = query.SubCategoryId != 0;
                var isCountryLevel      = query.CountryId != 0;
                var isStateLevel        = query.StateId != 0;
                var isCityLevel         = query.CityId != 0;
                var isOnlineExperiences = false;
                var EventCategory       = query.MasterEventType == Contracts.Enums.MasterEventType.Online ? _eventCategory.GetAll().Where(s => s.MasterEventTypeId == Contracts.Enums.MasterEventType.Online).FirstOrDefault() : _eventCategory.Get(query.CategoryId);
                var allCategories       = new List <FIL.Contracts.DataModels.EventCategory>();
                if (EventCategory == null && query.PageType == Contracts.Enums.PageType.Category)
                {
                    return(new FeelUserJourneyQueryResult {
                    });
                }
                if (!isCountryLevel && query.PageType == Contracts.Enums.PageType.Country)
                {
                    return(new FeelUserJourneyQueryResult {
                    });
                }
                if (isCountryLevel && query.PageType == Contracts.Enums.PageType.Country)
                {
                    if (isCategoryLevel && query.CategoryId == 0) // If Global country/state/city page
                    {
                        isCategoryLevel = false;
                    }
                    if (isSubcategoryLevel && query.SubCategoryId == 0) // If Global country/state/city page
                    {
                        isSubcategoryLevel = false;
                    }
                    var country = _countryRepository.Get(query.CountryId);
                    if (country == null)
                    {
                        return(new FeelUserJourneyQueryResult {
                        });
                    }
                }
                var subCategories = _eventCategory.GetByEventCategoryId(query.CategoryId).Where(s => s.IsEnabled).ToList();
                if (query.MasterEventType == Contracts.Enums.MasterEventType.Online || query.MasterEventType == Contracts.Enums.MasterEventType.InRealLife)
                {
                    isOnlineExperiences = query.MasterEventType == Contracts.Enums.MasterEventType.Online ? true : false;
                    allCategories       = _eventCategory.GetAll().ToList();
                    var parentCategoryIds = allCategories.Where(s => s.MasterEventTypeId == query.MasterEventType).Select(s => s.Id);
                    subCategories = allCategories.Where(s => parentCategoryIds.Any(p => p == s.EventCategoryId)).ToList();
                }
                if (isSubcategoryLevel)
                {
                    subCategories = subCategories.Where(s => s.Id == query.SubCategoryId).ToList();
                }
                var firstEventCategory = _eventCategory.Get(subCategories.FirstOrDefault().EventCategoryId);
                if (firstEventCategory != null && (!isCountryLevel && !isStateLevel && !isCategoryLevel && !isCityLevel && !isSubcategoryLevel))
                {
                    isOnlineExperiences = firstEventCategory.MasterEventTypeId == Contracts.Enums.MasterEventType.Online ? true : false;
                }
                var placeDetails = _placeProvider.GetAllPlaces(query, subCategories, EventCategory, query.MasterEventType, isCountryLevel, isStateLevel, isCityLevel).Where(s => s.CurrencyId != 0 && !s.IsTokenize).ToList();
                if (!placeDetails.Any())
                {
                    return(new FeelUserJourneyQueryResult {
                    });
                }
                var pageDetail = new PageDetail
                {
                    PageType           = query.PageType,
                    PagePath           = query.PagePath,
                    IsCategoryLevel    = isCategoryLevel,
                    IsSubCategoryLevel = isSubcategoryLevel,
                    IsCountryLevel     = isCountryLevel,
                    IsStateLevel       = isStateLevel,
                    IsCityLevel        = isCityLevel
                };
                List <DynamicPlaceSections> DynamicPlaceSections = new List <DynamicPlaceSections>();
                CountryPageDetail           countryPageDetail    = new CountryPageDetail();
                DynamicPlaceSections        AllplaceTiles        = new DynamicPlaceSections();
                List <GeoLocation>          Cities           = new List <GeoLocation>();
                List <GeoLocation>          States           = new List <GeoLocation>();
                List <GeoLocation>          Countries        = new List <GeoLocation>();
                List <SubCategory>          allSubCategories = new List <SubCategory>();

                if (((!isCityLevel || isCategoryLevel) && query.PageType == Contracts.Enums.PageType.Category) ||
                    (query.PageType == Contracts.Enums.PageType.Country && (!isSubcategoryLevel && !isCityLevel))
                    ) // Get subcat for category => category/country/state OR Country => category/country/state
                {
                    if (query.MasterEventType == Contracts.Enums.MasterEventType.Online || query.MasterEventType == Contracts.Enums.MasterEventType.InRealLife)
                    {
                        subCategories = allCategories.Where(s => s.MasterEventTypeId == query.MasterEventType).ToList();
                    }
                    if (((isCountryLevel || isStateLevel || isCityLevel) && query.PageType == Contracts.Enums.PageType.Category) ||
                        ((isStateLevel || isCityLevel || isCountryLevel) && (isCategoryLevel) && query.PageType == Contracts.Enums.PageType.Category)) // filter the subcat if it's category => state/country or country => category page
                    {
                        subCategories = subCategories.Where(x => placeDetails.Any(y => y.EventCategoryId == x.Id)).ToList();
                    }
                    else if (query.PageType == Contracts.Enums.PageType.Country && !isCategoryLevel && !isSubcategoryLevel) // Global country/city/state landing page
                    {
                        subCategories = _eventCategory.GetByIds(placeDetails.Select(s => s.ParentCategoryId).Distinct()).ToList();
                    }
                    allSubCategories = _subCategoryProvider.GetSubCategories(query, placeDetails, subCategories, pageDetail).OrderBy(s => s.Order).ToList();
                }

                if (((!isCityLevel || isCountryLevel) && pageDetail.PageType == Contracts.Enums.PageType.Category) ||
                    (pageDetail.PageType == Contracts.Enums.PageType.Country && !(isSubcategoryLevel && isCityLevel)))
                {
                    var cityGroup  = placeDetails.Select(s => new { s.CityId, s.CityName }).Distinct().Take(10);
                    var stateGroup = placeDetails.Select(s => new { s.StateId, s.StateName }).Distinct().Take(10);
                    // If it's online then don't show city/state/country
                    if (!isOnlineExperiences)
                    {
                        foreach (var group in cityGroup)
                        {
                            GeoLocation city = new GeoLocation();
                            if (group.CityName != "")
                            {
                                Cities.Add(GeoLocation(group.CityName, group.CityId, placeDetails.First().ParentCategorySlug, subCategories.First().Slug, isCategoryLevel, placeDetails.First().ParentCategoryId, subCategories.First().Id, query.CountryId, "city", pageDetail));
                            }
                        }
                        foreach (var group in stateGroup)
                        {
                            GeoLocation state = new GeoLocation();
                            if (group.StateName != "")
                            {
                                States.Add(GeoLocation(group.StateName, group.StateId, placeDetails.First().ParentCategorySlug, subCategories.First().Slug, isCategoryLevel, placeDetails.First().ParentCategoryId, subCategories.First().Id, query.CountryId, "state", pageDetail));
                            }
                        }
                        if (query.PageType == Contracts.Enums.PageType.Category)
                        {
                            var countryGroup = placeDetails.Select(s => new { s.CountryId, s.CountryName }).Distinct().Take(10);
                            foreach (var group in countryGroup)
                            {
                                GeoLocation country = new GeoLocation();
                                if (group.CountryName != "")
                                {
                                    Countries.Add(GeoLocation(group.CountryName, group.CountryId, placeDetails.First().ParentCategorySlug, subCategories.First().Slug, isCategoryLevel, placeDetails.First().ParentCategoryId, subCategories.First().Id, query.CountryId, "country", pageDetail));
                                }
                            }
                        }
                    }
                    DynamicPlaceSections = _dynamicSectionProvider.GetDynamicSections(placeDetails, query.MasterEventType, pageDetail);
                }

                AllplaceTiles.PlaceDetails   = placeDetails.Take(320).ToList();
                AllplaceTiles.SectionDetails = new SectionDetail();
                if (query.MasterEventType == Contracts.Enums.MasterEventType.Online || query.MasterEventType == Contracts.Enums.MasterEventType.InRealLife)
                {
                    AllplaceTiles.SectionDetails.Heading = query.MasterEventType == Contracts.Enums.MasterEventType.Online ? "Top Online Experiences from around the World" :
                                                           "In-Real-Life experiences around the world";
                }
                else if (query.PageType == Contracts.Enums.PageType.Category)
                {
                    AllplaceTiles.SectionDetails.Heading = (isCategoryLevel ? EventCategory.DisplayName : subCategories.First().DisplayName) + (isOnlineExperiences ? " from around " : " around ") +
                                                           (isCountryLevel ? placeDetails.First().CountryName : isStateLevel ?
                                                            placeDetails.First().StateName : isCityLevel ? placeDetails.First().CityName : "the World");
                }
                else if (query.PageType == Contracts.Enums.PageType.Country)
                {
                    AllplaceTiles.SectionDetails.Heading = ((!pageDetail.IsCategoryLevel && !pageDetail.IsSubCategoryLevel) ? "Feels"
                        : pageDetail.IsCategoryLevel
                        ? placeDetails.First().ParentCategory
                        : pageDetail.IsSubCategoryLevel ? placeDetails.First().Category : "") + (isOnlineExperiences ? " from around " : " around ") + (pageDetail.IsCityLevel
                        ? placeDetails.First().CityName :
                                                                                                                                                        pageDetail.IsStateLevel ? placeDetails.First().StateName : placeDetails.First().CountryName);
                }
                AllplaceTiles.SectionDetails.IsShowMore = true;
                var searchValue = "";
                if (query.MasterEventType == Contracts.Enums.MasterEventType.Online || query.MasterEventType == Contracts.Enums.MasterEventType.InRealLife)
                {
                    searchValue = "";
                }
                else if (query.PageType == Contracts.Enums.PageType.Category)
                {
                    searchValue = placeDetails.First().ParentCategory + (isSubcategoryLevel ? ", " + placeDetails.First().Category : "") +
                                  (isCountryLevel ? ", " + placeDetails.First().CountryName : "") + (isStateLevel ? ", " + placeDetails.First().StateName : "") +
                                  (isCityLevel ? ", " + placeDetails.First().CityName : "");
                }
                else
                {
                    searchValue = placeDetails.First().CountryName + (isSubcategoryLevel ? ", " + placeDetails.First().Category : "" + (isCategoryLevel ? ", " + placeDetails.First().ParentCategory : "")) +
                                  (isStateLevel ? ", " + placeDetails.First().StateName : "") +
                                  (isCityLevel ? ", " + placeDetails.First().CityName : "");
                }
                if (query.PageType == Contracts.Enums.PageType.Country)
                {
                    DynamicPlaceSections = DynamicPlaceSections.OrderBy(a => Guid.NewGuid()).ToList();
                    var description = "";
                    if (pageDetail.IsCityLevel)
                    {
                        var cityDescription = _cityDescriptionRepository.GetBycityId(placeDetails.First().CityId);
                        description = cityDescription != null ? cityDescription.Description : "";
                    }
                    else if (pageDetail.IsStateLevel)
                    {
                        var stateDescription = _stateDescriptionRepository.GetByStateId(placeDetails.First().StateId);
                        description = stateDescription != null ? stateDescription.Description : "";
                    }
                    else
                    {
                        var countryDescription = _countryDescriptionRepository.GetByCountryId(query.CountryId);
                        description = countryDescription != null ? countryDescription.Description : "";
                    }
                    countryPageDetail.Count        = (pageDetail.IsCountryLevel && !pageDetail.IsStateLevel && !pageDetail.IsCityLevel) ? _countryRepository.GetAllCountryPlace().Where(s => s.Id == query.CountryId).FirstOrDefault().Count : placeDetails.GroupBy(x => x.Name, (key, group) => group.First()).Count();
                    countryPageDetail.Description  = description;
                    countryPageDetail.SectionTitle = pageDetail.IsCityLevel ? placeDetails.First().CityName : isStateLevel?placeDetails.First().StateName:
                                                     placeDetails.First().CountryName;
                }

                return(new FeelUserJourneyQueryResult
                {
                    AllPlaceTiles = AllplaceTiles,
                    SubCategories = allSubCategories,
                    GeoData = new GeoData {
                        Cities = Cities, Countries = Countries, States = States
                    },
                    DynamicPlaceSections = DynamicPlaceSections,
                    SearchValue = searchValue,
                    ContryPageDetails = countryPageDetail,
                    Success = true
                });
            }
            catch (Exception e)
            {
                _logger.Log(LogCategory.Error, new Exception("", e));
                return(new FeelUserJourneyQueryResult
                {
                });
            }
        }
Пример #3
0
        public SearchVenueQueryResult Handle(SearchVenueQuery query)
        {
            List <FIL.Contracts.DataModels.SearchVenue> VenueResult = new List <Contracts.DataModels.SearchVenue>();

            try
            {
                var citiesArray = query.CityName != null?query.CityName.Split(",") : null;

                var eventCategoriesRepositoryData = _eventCategoryRepository.GetAll().Where(s => s.IsFeel == true);
                var categories = query.Categories != null?query.Categories.Split(",") : null;

                List <long> categoryList = new List <long>();
                if (categories != null && categories.Count() > 0 && query.PlaceId == 0)
                {
                    foreach (var item in categories)
                    {
                        try
                        {
                            var categoryInfo = eventCategoriesRepositoryData.FirstOrDefault(x => x.DisplayName == item).Id;
                            categoryList.Add(categoryInfo);
                        }
                        catch (Exception ex)
                        {
                            _logger.Log(Logging.Enums.LogCategory.Error, ex);
                        }
                    }
                }
                else if (categories != null && categories.Count() == 0 && query.PlaceId == 0)
                {
                    var categoryInfo = eventCategoriesRepositoryData.FirstOrDefault(x => x.DisplayName == query.Categories).Id;
                    categoryList.Add(categoryInfo);
                }
                var cityLists = query.CityIds != null?_cityRepository.GetByCityIds(query.CityIds) : null;

                var itineraryPlaces = query.PlaceId == 0 ? _eventRepository.GetAllItineraryPlaces(cityLists.Select(s => s.Id).ToList(), categoryList).GroupBy(x => x.Id, (key, group) => group.First()) :
                                      _eventRepository.GetItinerarySearchPlaces(query.PlaceId).GroupBy(x => x.Id, (key, group) => group.First());
                var placeWeekOpenDayList              = _placeWeekOpenDaysRepository.GetByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList());
                var dayTimeMappingLists               = _dayTimeMappingsRepository.GetAllByPlaceWeekOpenDays(placeWeekOpenDayList.Select(s => (long)s.Id).Distinct().ToList());
                var placeHolidayDatesRepositoryLists  = _placeHolidayDatesRepository.GetAllByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList());
                var placeVisitDurationRepositoryLists = _PlaceVisitDurationRepository.GetByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList());
                var eventDetails          = _eventDetailRepository.GetByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList()).Where(s => s.IsEnabled == true);
                var eventTicketDetails    = _eventTicketDetailRepository.GetByEventDetailIds(eventDetails.Select(s => (long)s.Id).Distinct().ToList()).Where(s => s.IsEnabled == true);
                var eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(eventTicketDetails.Select(s => (long)s.Id).Distinct().ToList()).Where(s => s.IsEnabled == true);
                var ticketCategories      = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetails.Select(s => (long)s.TicketCategoryId).Distinct().ToList());
                var Days = _daysRepository.GetAll();
                foreach (var currentPlace in itineraryPlaces)
                {
                    var         PlaceVisitDuration = placeVisitDurationRepositoryLists.FirstOrDefault(x => x.EventId == currentPlace.Id);
                    var         placeWeekOpenDays  = placeWeekOpenDayList.Where(x => x.EventId == currentPlace.Id);
                    var         dayTimeMappings    = dayTimeMappingLists.Where(s => placeWeekOpenDays.Any(p => p.Id == s.PlaceWeekOpenDayId));
                    SearchVenue searchVenue        = new SearchVenue();
                    searchVenue.CategoryName          = currentPlace.Category;
                    searchVenue.EventId               = currentPlace.Id;
                    searchVenue.CityId                = currentPlace.CityId;
                    searchVenue.EventSource           = currentPlace.EventSource;
                    searchVenue.CityName              = currentPlace.CityName;
                    searchVenue.CountryName           = currentPlace.CountryName;
                    searchVenue.Currency              = currentPlace.Currency;
                    searchVenue.EventName             = currentPlace.Name;
                    searchVenue.EventAltId            = currentPlace.AltId;
                    searchVenue.EventSlug             = currentPlace.Slug;
                    searchVenue.Address               = (currentPlace.AddressLineOne == null ? string.Empty : currentPlace.AddressLineOne) + "," + (currentPlace.AddressLineTwo == null ? string.Empty : currentPlace.AddressLineTwo);
                    searchVenue.Id                    = currentPlace.Id;
                    searchVenue.PlaceWeekOpenDays     = placeWeekOpenDays.ToList();
                    searchVenue.DayTimeMappings       = dayTimeMappings.ToList();
                    searchVenue.PlaceHolidaysList     = placeHolidayDatesRepositoryLists.Where(x => x.EventId == currentPlace.Id).ToList();
                    searchVenue.EventDescription      = currentPlace.EventDescription;
                    searchVenue.EventDetails          = eventDetails.Where(x => x.EventId == currentPlace.Id).ToList();
                    searchVenue.EventTicketDetails    = eventTicketDetails.Where(x => searchVenue.EventDetails.Any(s => s.Id == x.EventDetailId)).ToList();
                    searchVenue.EventTicketAttributes = eventTicketAttributes.Where(x => searchVenue.EventTicketDetails.Any(s => s.Id == x.EventTicketDetailId)).ToList();
                    searchVenue.ticketCategories      = ticketCategories.Where(x => searchVenue.EventTicketDetails.Any(s => s.TicketCategoryId == x.Id)).ToList();

                    if (currentPlace.Latitude != null)
                    {
                        var latArr  = currentPlace.Latitude.Split("E");
                        var longArr = currentPlace.Longitude.Split("E");
                        searchVenue.Latitude  = latArr[0];
                        searchVenue.Longitude = longArr[0];
                    }
                    else
                    {
                        searchVenue.Latitude  = null;
                        searchVenue.Longitude = null;
                    }
                    VenueResult.Add(searchVenue);
                }
                return(new SearchVenueQueryResult()
                {
                    Venues = VenueResult.Distinct().ToList(), Days = Days.ToList()
                });
            }
            catch (Exception e)
            {
                return(new SearchVenueQueryResult()
                {
                    Venues = VenueResult.Distinct().ToList()
                });
            }
        }