Пример #1
0
        public EventSearchResult Build(InfiniteFeelAnalyticsItem item, EventCategoryQueryResult ParentCategory)
        {
            try
            {
                UpdateInfiniteFeelAnalyticsItem(item);

                var parentCategory = ParentCategory.EventCategories.Where(w => w.Category == item.Category).FirstOrDefault();

                //Logic to check if parentCategory variable is null or not [Sentry error handling NullReferenceException]
                int parentId = -1;
                if (parentCategory != null)
                {
                    parentId = parentCategory.EventCategoryId;
                }

                var parent = ParentCategory.EventCategories.Where(w => w.Id == parentId).FirstOrDefault();
                if (parent != null)
                {
                    EventSearchResult _EventSearchResult = new EventSearchResult
                    {
                        AltId          = new Guid(item.DeDuplicator), // DeDuplicator returning the altIds
                        Name           = item.Name,
                        ParentCategory = parent.Category,
                        CityName       = item.City,
                        CountryName    = item.Country,
                        RedirectUrl    = item.Url
                    };
                    return(_EventSearchResult);
                }
                else
                {
                    EventSearchResult _EventSearchResult = new EventSearchResult
                    {
                        AltId          = new Guid(item.DeDuplicator), // DeDuplicator returning the altIds
                        Name           = item.Name,
                        ParentCategory = "SeeAndDo",
                        CityName       = item.City,
                        CountryName    = item.Country,
                        RedirectUrl    = item.Url
                    };
                    return(_EventSearchResult);
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, ex);
                UpdateInfiniteFeelAnalyticsItem(item);
                EventSearchResult _EventSearchResult = new EventSearchResult
                {
                    AltId          = new Guid(item.DeDuplicator), // DeDuplicator returning the altIds
                    Name           = item.Name,
                    ParentCategory = "SeeAndDo",
                    CityName       = item.City,
                    CountryName    = item.Country,
                    RedirectUrl    = item.Url
                };

                return(_EventSearchResult);
            }
        }
Пример #2
0
        public async Task <IActionResult> SearchEvents([FromForm] EventSearchViewModel modelFromForm)
        {
            EventSearchResult events = await _searchRequest.Search(modelFromForm.Location, modelFromForm.Keyword);

            modelFromForm.SearchResults = events;

            return(PartialView("_ShowEvents", modelFromForm));
        }
Пример #3
0
        public EventSearchResult Build(CategoryEventContainer container)
        {
            var city  = container.City.FirstOrDefault();
            var state = container.State.FirstOrDefault(s => city == null || s.Id == city.StateId);
            EventSearchResult _EventSearchResult = new EventSearchResult
            {
                AltId          = container.CategoryEvent.AltId,
                Name           = container.CategoryEvent.Name,
                ParentCategory = container.ParentCategory,
                CityName       = city?.Name ?? string.Empty,
                CountryName    = container.Country.FirstOrDefault(c => state == null || c.Id == state.CountryId)?.Name ?? string.Empty,
                RedirectUrl    = "https://" + GetBaseUrl() + "/place/" + container.ParentCategory.Replace("&", "and").Replace(" ", "-").ToLower() + "/" + container.Event.Slug.ToString().ToLower() + "/" + container.EventCategory.Replace("&", "and").Replace(" ", "-").ToLower()
            };

            return(_EventSearchResult);
        }
Пример #4
0
        public async Task <EventSearchResult> Search(string location, string eventKeyword)
        {
            string url = $"http://api.eventful.com/json/events/search?...&keywords={eventKeyword}&location={location}&date=Future&app_key={API_Keys.EventfulAppKey}";

            using HttpClient client = new HttpClient();
            {
                HttpResponseMessage response = await client.GetAsync(url);

                if (response.IsSuccessStatusCode)
                {
                    string json = await response.Content.ReadAsStringAsync();

                    EventSearchResult events = JsonConvert.DeserializeObject <EventSearchResult>(json);
                    return(events);
                }
            }
            return(null);
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RestApiEventSearchPaginationResult" /> class.
 /// </summary>
 /// <param name="data">Event results (required).</param>
 /// <param name="page">Current page index (required).</param>
 /// <param name="limit">Current page size (required).</param>
 /// <param name="totalRecordCount">Total record count (required).</param>
 public RestApiEventSearchPaginationResult(EventSearchResult data = default(EventSearchResult), int?page = default(int?), int?limit = default(int?), int?totalRecordCount = default(int?))
 {
     // to ensure "data" is required (not null)
     if (data == null)
     {
         throw new InvalidDataException("data is a required property for RestApiEventSearchPaginationResult and cannot be null");
     }
     else
     {
         this.Data = data;
     }
     // to ensure "page" is required (not null)
     if (page == null)
     {
         throw new InvalidDataException("page is a required property for RestApiEventSearchPaginationResult and cannot be null");
     }
     else
     {
         this.Page = page;
     }
     // to ensure "limit" is required (not null)
     if (limit == null)
     {
         throw new InvalidDataException("limit is a required property for RestApiEventSearchPaginationResult and cannot be null");
     }
     else
     {
         this.Limit = limit;
     }
     // to ensure "totalRecordCount" is required (not null)
     if (totalRecordCount == null)
     {
         throw new InvalidDataException("totalRecordCount is a required property for RestApiEventSearchPaginationResult and cannot be null");
     }
     else
     {
         this.TotalRecordCount = totalRecordCount;
     }
 }