private void PopulateDefaultQuery(SearchEventsPortalRequest searchRequest)
        {
            var sorting = GetDropDownValue("Sorting");
            if (sorting != null)
            {
                searchRequest.SortOrder = sorting;

                if (sorting == "Random")
                    searchRequest.RandomSort = true;
                else
                    searchRequest.RandomSort = false;
            }

            var keywords = _viewSettings.GetSettingValue("Keyword", string.Empty);
            if (!string.IsNullOrWhiteSpace(keywords))
                searchRequest.Keyword = keywords;

            var location = _viewSettings.GetDropdownSettingValue("Location");
            if (location.Value != null)
                searchRequest.OrganizationalUnitId = int.Parse(location.Value.ToString());

            var searchRadius = GetDropDownValue("SearchWithin");
            if (searchRadius != null)
                if (searchRadius != "Any")
                    searchRequest.SearchRadius = int.Parse(searchRadius);

            var topic = _viewSettings.GetDropdownSettingValue("Topic");
            if (topic.Value != null)
                searchRequest.EventTopicId = int.Parse(topic.Value.ToString());

            var type = _viewSettings.GetDropdownSettingValue("Type");
            if (type.Value != null)
                searchRequest.EventTypeId = int.Parse(type.Value.ToString());
        }
 /// <summary>
 /// Determines whether the specified <see cref="SearchEventsPortalRequest" /> is equal to this instance.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 public bool Equals(SearchEventsPortalRequest other)
 {
     return base.Equals(other)
         && string.Equals(SortOrder, other.SortOrder, StringComparison.OrdinalIgnoreCase)
         && string.Equals(WebUrl, other.WebUrl, StringComparison.OrdinalIgnoreCase)
         && string.Equals(RadiusUnit, other.RadiusUnit, StringComparison.OrdinalIgnoreCase)
         && bool.Equals(ShowEventsWithNoDatesFirst, other.ShowEventsWithNoDatesFirst)
         && SearchRadius == other.SearchRadius
         && IncludeCalendarSchedules.Equals(other.IncludeCalendarSchedules)
         && CalendarDateRangeStart.Equals(other.CalendarDateRangeStart)
         && CalendarDateRangeEnd.Equals(other.CalendarDateRangeEnd);
 }
        private SearchEventsPortalRequest BuildRequest(IDictionary<string, string> parameters, int pageSize, int pageNumber)
        {
            var searchRequest = new SearchEventsPortalRequest()
            {
                PageSize = pageSize,
                RequestedPage = pageNumber
            };

            //Location Context
            searchRequest.OrganizationalUnitId = LocationContextHelper.ResolveLocationContext(_view, _viewSettings, parameters).Id;
            searchRequest.DescendantOption = LocationContextHelper.ResolveLocationDescendantOption(_viewSettings, parameters);

            PopulateDefaultQuery(searchRequest);

            //Keyword
            if (parameters.ContainsKey("Keyword"))
                searchRequest.Keyword = parameters["Keyword"];
            //Event Title
            if (parameters.ContainsKey("EventId"))
                searchRequest.Title = parameters["EventId"];
            if (parameters.ContainsKey("EventText"))
                searchRequest.Title = parameters["EventText"];
            //Location
            if (parameters.ContainsKey("LocationId"))
                searchRequest.OrganizationalUnitId = int.Parse(parameters["LocationId"]);
            if (parameters.ContainsKey("LocationText"))
                searchRequest.OrganizationalUnitName = parameters["LocationText"];
            //Event Topic
            if (parameters.ContainsKey("EventTopicId"))
                searchRequest.EventTopicId = int.Parse(parameters["EventTopicId"]);
            else if (parameters.ContainsKey("EventTopicText"))
                searchRequest.EventTopicName = parameters["EventTopicText"];
            //Event Type
            if (parameters.ContainsKey("EventTypeId"))
                searchRequest.EventTypeId = int.Parse(parameters["EventTypeId"]);
            else if (parameters.ContainsKey("EventTypeText"))
                searchRequest.EventTypeName = parameters["EventTypeText"];
            //Start Date
            if (parameters.ContainsKey("StartDate"))
                searchRequest.EventStartDate = DateTime.Parse(parameters["StartDate"]);
            //End Date
            if (parameters.ContainsKey("EndDate"))
                searchRequest.EventEndDate = DateTime.Parse(parameters["EndDate"]);
            //Postal Code
            if (parameters.ContainsKey("PostalCode"))
                searchRequest.PostalCode = parameters["PostalCode"];
            //Search Radius
            if (parameters.ContainsKey("RadiusDistance") && !string.IsNullOrEmpty(parameters["RadiusDistance"]))
                searchRequest.SearchRadius = int.Parse(parameters["RadiusDistance"]);

            return searchRequest;
        }
 private static SearchEventsPortalRequest CreateRequest()
 {
     var request = new SearchEventsPortalRequest();
     return request;
 }