Пример #1
0
        public IActionResult Detail(string categoryName, string parentCategoryName, string subParentCategoryName)
        {
            if (categoryName.Contains(".") || categoryName.Contains("src") || categoryName.ToLower().Contains("true") || categoryName.ToLower().Contains("false"))
            {
                return(RedirectPermanent(categoryName));
            }

            var sa = $"/{categoryName}";

            if (!string.IsNullOrEmpty(parentCategoryName))
            {
                sa = $"/{parentCategoryName}/{categoryName}";
            }

            if (!string.IsNullOrEmpty(subParentCategoryName))
            {
                sa = $"/{parentCategoryName}/{subParentCategoryName}/{categoryName}";
            }

            var categoryModel = _categoryService.GetByUrl(sa);

            if (categoryModel == null)
            {
                return(RedirectToAction("Page", "StaticPages", new { pageUrl = categoryName }));
            }

            var t = _categoriesSliderService.GetGalleriesByCategoryId(categoryModel.Id);

            var s = new List <string>();

            s.AddRange(t.Select(x => x.GalleryId).ToList <string>());
            var subCategory = _categoryService.GetAllSubCategories(categoryModel.Id).ToList();
            var imgs        = new Dictionary <int, string>();

            subCategory.ForEach(x => imgs.Add(x.Id, x.ImagePath));

            CategoryModel cm = new CategoryModel(_galleryPoolService, s, imgs);

            //ViewBag.SubCategories = subCategory;
            ViewBag.CategorySlider = cm;
            var subCategoryList = _categoryService.GetAllSubCategories(categoryModel.Id).ToList();

            foreach (var item in subCategoryList)
            {
                subCategoryList.FirstOrDefault(x => x.Id == item.Id).SubCategory = _categoryService.GetAllSubCategories(item.Id).ToList();
            }

            ViewBag.SubCategories = subCategoryList;
            var tourList = new List <TourDTO>();

            if (_categoryService.GetAllSubCategories(categoryModel.Id).Count() == 0)
            {
                var categoryTours = _tourCategoryService.GetAllByCategoriesofTours(categoryModel.Id).ToList();
                foreach (var item in categoryTours)
                {
                    tourList.Add(_tourService.GetTourById(item.TourId));
                }
            }
            ViewBag.TourList = tourList;

            return(View(categoryModel));
        }
Пример #2
0
        public JsonResult CategoryGalleryDelete(int categoryId, string galleryId)
        {
            var categoryGallery = _categoriesSliderService.GetGalleriesByCategoryId(categoryId)?.First(x => x.GalleryId == galleryId) ?? null;

            return(Json(categoryGallery != null ? _categoriesSliderService.DeleteCategory(categoryGallery) : false));
        }