Ejemplo n.º 1
0
        /// <summary>
        /// Indexes this instance.
        /// </summary>
        /// <param name="value">Name of Country/City/Name you want to display.</param>
        /// <param name="key">Group Of the Display Name.</param>
        /// <returns>
        /// view for home
        /// </returns>
        public async Task <IActionResult> Index(string value, string key)
        {
            if (value != null)
            {
                this.ViewBag.Display = value;
                this.ViewBag.Group   = key;
            }

            try
            {
                var searchKey = KeyCreator.Create(DateTime.Now.ToString("dd/MM/yyyy"));

                var homepageConfigRs =
                    await
                    this.tableCacheHandler.GetFromCacheAsync(
                        searchKey,
                        () => this.homePageBusiness.GetHomePageConfiguration(),
                        SearchExpiryInSeconds);

                var result = homepageConfigRs.Result;
                this.ViewBag.PageType              = result.PageType;
                this.ViewBag.TravelStyle           = result.TravelStyle;
                this.ViewBag.BannersList           = result.BannersList;
                this.ViewBag.PopularDestinations   = result.PopularDestinations;
                this.ViewBag.CurationBanner        = result.CurationBanner;
                this.ViewBag.BlogPosts             = result.BlogPosts;
                this.ViewBag.FlashDeals            = result.FlashDeals;
                this.ViewBag.DealOfMonth           = result.DealOfMonth;
                this.ViewBag.LocationBasedCuration = result.LocationBasedCuration;
            }
            catch (Exception ex)
            {
                var msg = ex.ToString();
            }

            return(this.View());
        }
        public async Task <IActionResult> SearchHolidayProduct(
            bool showSearchTerm,
            int searchType,
            int value,
            string searchTerm,
            string subSearchTerm,
            int adults       = 1,
            int kids         = 0,
            int infants      = 0,
            int rooms        = 1,
            string kidsage   = null,
            string startDate = null,
            string endDate   = null)
        {
            Tuple <int, int, bool, string> valueSearchType;

            valueSearchType = await this.listingService.GetProductUrlAsync(searchTerm);

            if (valueSearchType.Item2 == (int)Enums.SearchType.Product)
            {
                return(this.RedirectToAction("Holiday", "Deal", new { url = valueSearchType.Item4 }));
            }

            this.ViewBag.startDate      = startDate;
            this.ViewBag.endDate        = endDate;
            this.ViewBag.adults         = adults;
            this.ViewBag.kids           = kids;
            this.ViewBag.infants        = infants;
            this.ViewBag.rooms          = rooms;
            this.ViewBag.searchTerm     = searchTerm;
            this.ViewBag.showSearchTerm = valueSearchType.Item3;
            ListingViewModel listingModel = new ListingViewModel();

            listingModel.SearchTermViewModel = new SearchTermViewModel
            {
                Adults         = adults,
                EndDate        = endDate,
                SearchType     = valueSearchType.Item2,
                StartDate      = startDate,
                Kids           = kids,
                Infants        = infants,
                Rooms          = rooms,
                SearchTerm     = searchTerm,
                ShowSearchTerm = valueSearchType.Item3,
                Value          = valueSearchType.Item1,
                KidsAge        = kidsage,
                StartDateVar   = !string.IsNullOrEmpty(startDate) ? DateTime.ParseExact(startDate, "dd-MM-yyyy", null) : DateTime.Now.Date,
                EndDateVar     = !string.IsNullOrEmpty(endDate) ? DateTime.ParseExact(endDate, "dd-MM-yyyy", null) : DateTime.Now.Date.AddYears(1),
            };

            if (!string.IsNullOrEmpty(startDate))
            {
                this.TempData["StartDate"] = listingModel.SearchTermViewModel.StartDateVar;
            }
            else
            {
                this.TempData["StartDate"] = null;
            }

            if (!string.IsNullOrEmpty(endDate))
            {
                this.TempData["EndDate"] = listingModel.SearchTermViewModel.EndDateVar;
            }
            else
            {
                this.TempData["EndDate"] = null;
            }

            ListingViewModel result = new ListingViewModel();

            try
            {
                var searchkey = KeyCreator.Create(listingModel);
                var productRs =
                    await
                    this.tableCacheHandler.GetFromCacheAsync(
                        searchkey,
                        () => this.homePageBusiness.GetSearchResults(listingModel),
                        SearchExpiryInSeconds);

                result = productRs.Result;
            }
            catch (Exception ex)
            {
                result = this.listingService.GetSearchResults(listingModel);
                string msg = ex.ToString();
            }

            this.ViewBag.FilterActivated = false;
            if (result.ResultViewModels.Count == 0)
            {
                result.TrendingDeals = this.listingService.GetTop6TrendingDeals();
            }

            return(this.View("Search", result));
        }
        public async Task <IActionResult> SearchOneLevel(
            bool showSearchTerm,
            int searchType,
            int value,
            string searchTerm,
            int adults       = 1,
            int kids         = 0,
            int infants      = 0,
            int rooms        = 1,
            string kidsage   = null,
            string startDate = null,
            string endDate   = null)
        {
            Tuple <int, int, bool> valueSearchType;

            if (searchTerm.ToLower() == "flash-deal")
            {
                valueSearchType = new Tuple <int, int, bool>(0, (int)Enums.SearchType.FlashDeal, false);
            }
            else if (searchTerm.ToLower() == "deals-of-the-month")
            {
                valueSearchType = new Tuple <int, int, bool>(0, (int)Enums.SearchType.DealOfTheMonth, false);
            }
            else
            {
                valueSearchType =
                    await this.listingService.GetValueListTypeOfSearchCountryTravelStyleAsync(searchTerm);
            }

            this.ViewBag.startDate      = startDate;
            this.ViewBag.endDate        = endDate;
            this.ViewBag.adults         = adults;
            this.ViewBag.kids           = kids;
            this.ViewBag.infants        = infants;
            this.ViewBag.rooms          = rooms;
            this.ViewBag.searchTerm     = searchTerm.Replace("-", " ");
            this.ViewBag.showSearchTerm = valueSearchType.Item3;
            ListingViewModel listingModel = new ListingViewModel();

            listingModel.SearchTermViewModel = new SearchTermViewModel
            {
                Adults         = adults,
                EndDate        = endDate,
                SearchType     = valueSearchType.Item2,
                StartDate      = startDate,
                Kids           = kids,
                Infants        = infants,
                Rooms          = rooms,
                SearchTerm     = searchTerm.Replace("-", " "),
                ShowSearchTerm = valueSearchType.Item3,
                Value          = valueSearchType.Item1,
                KidsAge        = kidsage,
                StartDateVar   = !string.IsNullOrEmpty(startDate) ? DateTime.ParseExact(startDate, "dd-MM-yyyy", null) : DateTime.Now.Date,
                EndDateVar     = !string.IsNullOrEmpty(endDate) ? DateTime.ParseExact(endDate, "dd-MM-yyyy", null) : DateTime.Now.Date.AddYears(1),
            };

            if (!string.IsNullOrEmpty(startDate))
            {
                this.TempData["StartDate"] = listingModel.SearchTermViewModel.StartDateVar;
            }
            else
            {
                this.TempData["StartDate"] = null;
            }

            if (!string.IsNullOrEmpty(endDate))
            {
                this.TempData["EndDate"] = listingModel.SearchTermViewModel.EndDateVar;
            }
            else
            {
                this.TempData["EndDate"] = null;
            }

            if (searchType == (int)Enums.SearchType.Product)
            {
                DealsPackageModel dealsPackageModel = await this.homePageService.GetDealPackageByIdAsync(listingModel.SearchTermViewModel.Value);

                if (dealsPackageModel.Type == 1) ////Hotel
                {
                    return(this.RedirectToAction("Hotel", "Deal", new { url = dealsPackageModel.Url }));
                }
                else
                {
                    return(this.RedirectToAction("Tour", "Deal", new { url = dealsPackageModel.Url }));
                }
            }

            ListingViewModel result = new ListingViewModel();

            try
            {
                var searchkey = KeyCreator.Create(listingModel);
                var productRs =
                    await
                    this.tableCacheHandler.GetFromCacheAsync(
                        searchkey,
                        () => this.homePageBusiness.GetSearchResults(listingModel),
                        SearchExpiryInSeconds);

                result = productRs.Result;
            }
            catch (Exception ex)
            {
                result = this.listingService.GetSearchResults(listingModel);
                string msg = ex.ToString();
            }

            this.ViewBag.FilterActivated = false;
            if (result.ResultViewModels.Count == 0)
            {
                result.TrendingDeals = this.listingService.GetTop6TrendingDeals();
            }

            return(this.View("Search", result));
        }