Пример #1
0
        public IActionResult Detail(string tourUrl, string tourPage)
        {
            ViewBag.urlPrefix = Request.Path.ToString().Contains(tourPage ?? "anasayfa") ? Request.Path.ToString().Split(tourPage)[0] : Request.Path.ToString();


            if (tourUrl.Contains(".") || tourUrl.Contains("src") || tourUrl.ToLower().Contains("true") || tourUrl.ToLower().Contains("false"))
            {
                return(RedirectPermanent(tourUrl));
            }
            var q = _tourService.GetTourByUrl(tourUrl);

            if (q != null)
            {
                //var breadCrumb = new List<string>();
                //breadCrumb.Add(q.TourName);

                var tourCategories = _tourCategoriesService.GetAllByTourIdCategoriesName(q.Id);
                ViewBag.Category = tourCategories;
                if (tourCategories != null)
                {
                    var qs           = _tourService.GetTourByCategoryId(tourCategories.First().CategoriesId);
                    var similarTours = new List <TourDTO>();
                    foreach (var item in qs)
                    {
                        similarTours.Add(_tourService.GetTourById(item.TourId));
                    }
                    ViewBag.SimilarTours = similarTours;
                }
                else
                {
                    ViewBag.SimilarTours = new List <TourDTO>();
                }

                //var breadCrumbCategory = tourCategories.FirstOrDefault(x => q.TourUrl.Contains(x.CategoriesName));
                //breadCrumb.Add(breadCrumbCategory.CategoriesName);

                //var secondTopCategory = _categoriesService.GetParentCategoryName(breadCrumbCategory.CategoriesId);
                //breadCrumb.Add(secondTopCategory.CategoryName);
                //breadCrumb.Add(_categoriesService.GetParentCategoryName(secondTopCategory.Id).CategoryName);



                ViewBag.TourDays = _tourPlanService.GetAll().Where(x => x.TourId == q.Id).ToList();
                if (tourPage == "tour-plan")
                {
                    ViewBag.TourDays = _tourPlanService.GetAll().Where(x => x.TourId == q.Id).ToList();
                    return(View("~/Views/Tour/tourplan.cshtml", q));
                }
                else if (tourPage == "tour-map")
                {
                    return(View("~/Views/Tour/tourmap.cshtml", q));
                }
                else if (tourPage == "hotel")
                {
                    return(View("~/Views/Tour/hotel.cshtml", q));
                }
                else if (tourPage == "conditions")
                {
                    ViewBag.TourDays = _tourPlanService.GetAll().Where(x => x.TourId == q.Id).ToList();
                    return(View("~/Views/Tour/conditions.cshtml", q));
                }
                else if (tourPage == "gallery")
                {
                    ViewBag.Gallery = _tourGalleryService.GetGalleriesByTourId(q.Id).ToList();
                    return(View("~/Views/Tour/gallery.cshtml", q));
                }

                return(View(q));
            }


            return(View(null));
        }