public async Task <IActionResult> CategoryDetail(string pageType, string pageTag, int id)
        {
            if (routeTable.Exists(pageTag, EntityName.Category, PageType.Detail) && routeTable.Exists(pageType, EntityName.Category, PageType.Normal))
            {
                Category Category = await cacheService.GetAsync($"{CacheInfo.Category}-{id}-{CurrentWebsite.id}", () =>
                                                                categoryService.GetAllLanguageCategory(x => x.id == id && x.WebSiteid == CurrentWebsiteId && x.IsActive == true)
                                                                );

                if (Category != null)
                {
                    List <Category> subCategories = await cacheService.GetAsync($"{CacheInfo.SubCategoryies}-{id}-{CurrentWebsite.id}-{Category.Languageid.Value}", () =>
                                                                                categoryService.GetMany(x => x.WebSite == CurrentWebsite && x.Parentid == Category.id && x.IsActive == true, Category.Languageid.Value).OrderByDescending(x => x.Priority).ToList()
                                                                                );

                    ICollection <Product> products = await cacheService.GetAsync($"{CacheInfo.SubProducts}-{id}-{Category.Languageid.Value}", () =>
                                                                                 productService.GetMany(x => x.Categoryid == Category.id && x.IsActive == true, Category.Languageid.Value)
                                                                                 );

                    if (Category.Languageid != CurrentLanguage.id)
                    {
                        LoadLanguage(true, Category.Languageid);
                    }

                    return(View(new ProductListViewModel()
                    {
                        Products = products,
                        CurrentCategory = Category,
                        SubCategories = subCategories
                    }));
                }
                else
                {
                    return(RedirectToAction("CategoryNotFound"));
                }
            }
            else
            {
                return(NotFoundPage());
            }
        }
Beispiel #2
0
        public async Task <IActionResult> PetroBlog(string blogPageName)
        {
            if (routeTable.Exists(blogPageName, Bll.Concreate.EntityName.Blog, Bll.Concreate.PageType.List))
            {
                ICollection <Blog> blogs = await cacheService.GetAsync($"{CacheInfo.OrderedBlogs}-{CurrentWebsite.id}-{CurrentLanguage.id}", () =>
                                                                       blogService
                                                                       .GetMany(x => x.WebSiteid == CurrentWebsite.id && x.IsActive == true, CurrentLanguage.id)
                                                                       .OrderByDescending(x => x.Priority)
                                                                       .ThenBy(x => x.CreateDate).ToList()
                                                                       );

                return(View(blogs));
            }
            return(NotFoundPage());
        }
Beispiel #3
0
 public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
 {
     return(routeTable.Exists(values[routeKey].ToString(), EntityName.Blog, PageType.Detail));
 }