public FiltersResult Filters([FromUri] FiltersParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            WebPartner partner = UserToolsProvider.GetPartner(param);

            if (!(param.StartPoint.HasValue || (param.StartPointAlias == null)))
            {
                param.sp = new int?(CatalogProvider.GetGeoPointIdByAlias(param.StartPointAlias));
            }
            object[] args = new object[5];
            args[0] = param.Language;
            args[1] = partner.id;
            args[2] = param.StartPoint.HasValue ? param.StartPoint.ToString() : "-";
            int?destinationState = param.DestinationState;

            args[3] = destinationState.HasValue ? (destinationState = param.DestinationState).ToString() : "-";
            args[4] = param.WithoutPrice;
            string        key    = string.Format("cache_filterResult[ln:{0}][p:{1}][sp:{2}][st:{3}][wp:{4}]", args);
            FiltersResult result = HttpContext.Current.Cache[key] as FiltersResult;

            if ((result == null) || Settings.IsCacheDisabled)
            {
                result = new FiltersResult();
                DateTime?startDate   = null;
                TimeSpan?minDuration = null;
                List <CatalogExcursionMinPrice> catalog = ExcursionProvider.FindExcursions(param.Language, partner.id, startDate, null, null, param.StartPoint, null, null, null, param.DestinationState.HasValue ? new int[] { param.DestinationState.Value } : null, null, minDuration, null, null, param.WithoutPrice);
                result.categorygroups = ExcursionProvider.BuildFilterCategories(catalog, null);
                result.destinations   = ExcursionProvider.BuildFilterDestinations(catalog, null);
                result.languages      = ExcursionProvider.BuildFilterLanguages(catalog, null);
                result.durations      = ExcursionProvider.BuildFilterDurations(catalog);
                HttpContext.Current.Cache.Add(key, result, null, DateTime.Now.AddMinutes(10.0), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
            }
            return(result);
        }
        private static FilterDetailsResult GetCachedFilterDetails(IStartPointAndLanguageAndPriceOptionParam param, WebPartner partner)
        {
            string filtersResultCacheKey = string.Format("cache_filterDetails[ln:{0}][p:{1}][sp:{2}][wp:{3}]", new object[]
            {
                param.Language,
                partner.id,
                param.StartPoint.HasValue ? param.StartPoint.ToString() : "-",
                param.WithoutPrice
            });
            FilterDetailsResult result = HttpContext.Current.Cache[filtersResultCacheKey] as FilterDetailsResult;

            if (result == null || Settings.IsCacheDisabled)
            {
                result = new FilterDetailsResult();
                System.Collections.Generic.List <CatalogExcursionMinPrice> excursions = ExcursionProvider.FindExcursions(param.Language, partner.id, null, null, null, param.StartPoint, null, null, null, null, null, null, null, null, param.WithoutPrice);
                result.categorygroups = ExcursionProvider.BuildFilterCategories(excursions, null);
                //   result.departures = ExcursionProvider.BuildFilterDepartures(excursions, null);
                result.languages = ExcursionProvider.BuildFilterLanguages(excursions, null);
                result.durations = ExcursionProvider.BuildFilterDurations(excursions);
                System.Collections.Generic.List <CatalogFilterLocationItem> destinations = ExcursionProvider.BuildFilterDestinations(excursions, null);
                if (destinations != null)
                {
                    result.destinations = new System.Collections.Generic.List <CatalogFilterLocationWithStateItem>();
                    if (destinations.Count > 0)
                    {
                        ExcursionProvider.LoadStatesResult stateResult = ExcursionProvider.LoadStatesForPoints(param.Language, (
                                                                                                                   from m in destinations
                                                                                                                   select m.id).ToArray <int>());
                        foreach (CatalogFilterLocationItem item in destinations)
                        {
                            int stateId;
                            if (stateResult.Links.TryGetValue(item.id, out stateId))
                            {
                                result.destinations.Add(new CatalogFilterLocationWithStateItem(item, stateId.ToString()));
                            }
                            else
                            {
                                result.destinations.Add(new CatalogFilterLocationWithStateItem(item, null));
                            }
                        }
                        result.destinationstates = stateResult.States;
                    }
                }
                HttpContext.Current.Cache.Add(filtersResultCacheKey, result, null, System.DateTime.Now.AddMinutes(10.0), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
            }
            return(result);
        }