public ExcursionPriceList Price(int id, [FromUri] PriceParam param)
        {
            if (param == null)
            {
                throw new System.ArgumentNullException("param");
            }
            WebPartner partner = UserToolsProvider.GetPartner(param);

            if (!param.Date.HasValue)
            {
                throw new ArgumentNullExceptionWithCode(202, "date");
            }
            if (!param.StartPoint.HasValue && param.StartPointAlias != null)
            {
                param.sp = new int?(CatalogProvider.GetGeoPointIdByAlias(param.StartPointAlias));
            }
            ExcursionPriceList result;

            if (param.Date.Value.Date < System.DateTime.Today)
            {
                result = new ExcursionPriceList(new System.Collections.Generic.List <ExcursionPrice>());
            }
            else
            {
                System.Collections.Generic.List <ExcursionPrice> prices = ExcursionProvider.GetPrice(param.Language, partner.id, id, param.Date.Value, param.StartPoint);
                result = new ExcursionPriceList((
                                                    from m in prices
                                                    where !m.issaleclosed && !m.isstopsale && m.price != null && !(m.totalseats >= 0 && !m.freeseats.HasValue)
                                                    select m).ToList <ExcursionPrice>());
            }

            return(result);
        }
 public CategoryGroupWithCategoriesList CategoriesByGroup([FromUri] CategoryParam param)
 {
     if (param == null)
     {
         throw new ArgumentNullException("param");
     }
     if (!(param.StartPoint.HasValue || (param.StartPointAlias == null)))
     {
         param.sp = new int?(CatalogProvider.GetGeoPointIdByAlias(param.StartPointAlias));
     }
     return(new CategoryGroupWithCategoriesList(ExcursionProvider.GetCategoriesByGroup(param.Language, param.StartPoint)));
 }
        public FilterDetailsResult FilterDetails([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));
            }
            return(GetCachedFilterDetails(param, partner));
        }
        public SearchExcursionResult Search([FromUri] SearchParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (string.IsNullOrEmpty(param.SearchText))
            {
                throw new ArgumentNullExceptionWithCode(0x65, "s");
            }
            if (!(param.StartPoint.HasValue || (param.StartPointAlias == null)))
            {
                param.sp = new int?(CatalogProvider.GetGeoPointIdByAlias(param.StartPointAlias));
            }
            int limit = (param.SearchLimit.HasValue && (param.SearchLimit.Value > 0)) ? param.SearchLimit.Value : Settings.ExcursionGeographySearchLimit;

            return(ExcursionProvider.SearchExcursionObjects(param.Language, param.StartPoint, param.SearchText, limit));
        }
        public CatalogResult Catalog([FromUri] CatalogParam param)
        {
            if (param == null)
            {
                throw new System.ArgumentNullException("param");
            }

            if (param.dp != null)
            {
                param.d = null;
            }

            WebPartner partner = UserToolsProvider.GetPartner(param);

            if (!param.StartPoint.HasValue && param.StartPointAlias != null)
            {
                param.sp = new int?(CatalogProvider.GetGeoPointIdByAlias(param.StartPointAlias));
            }
            ExcursionProvider.ExcursionSorting sorting = (!string.IsNullOrEmpty(param.SortOrder)) ? ((ExcursionProvider.ExcursionSorting)System.Enum.Parse(typeof(ExcursionProvider.ExcursionSorting), param.SortOrder)) : ExcursionProvider.ExcursionSorting.name;

            //получить id экскурсий в регионе

            //фильтровать по id

            CatalogResult result = new CatalogResult();

            result.excursions = ExcursionProvider.FindExcursions(param.Language, partner.id, param.FirstDate, param.LastDate, param.SearchLimit, param.StartPoint, param.SearchText, param.Categories, param.Departures, (param.Destinations != null && param.Destinations.Length > 0) ? param.Destinations : (param.DestinationState.HasValue ? new int[]
            {
                param.DestinationState.Value
            } : null), param.ExcursionLanguages, param.MinDuration, param.MaxDuration, new ExcursionProvider.ExcursionSorting?(sorting), param.WithoutPrice);
            System.Collections.Generic.Dictionary <int, ExcursionRank> rankings = SurveyProvider.GetExcursionsRanking((
                                                                                                                          from m in result.excursions
                                                                                                                          select m.excursion.id).ToList <int>(), param.Language);

            foreach (CatalogExcursionMinPrice excursion in result.excursions)
            {
                ExcursionRank rank = null;
                if (rankings.TryGetValue(excursion.excursion.id, out rank))
                {
                    excursion.ranking = CatalogExcursionRanking.Create(rank, param.Language);
                }
            }
            return(result);
        }
        public DestinationsAndCategoryGroupsResult DestinationsAndCategoryGroups([FromUri] DestinationAndCategoryParam 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));
            }
            DestinationsAndCategoryGroupsResult result = new DestinationsAndCategoryGroupsResult();
            FilterDetailsResult cachedFilterDetails    = GetCachedFilterDetails(param, partner);

            result.destinationstates = cachedFilterDetails.destinationstates;
            result.categorygroups    = ExcursionProvider.GetCategoriesByGroup(param.Language, param.StartPoint);
            return(result);
        }
        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);
        }