예제 #1
0
        public IActionResult Category(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(404));
            }

            var category = categoryCache.FromKey(id.Value);

            if (category == null)
            {
                return(new HttpStatusCodeResult(404));
            }

            var ids = categoryCache.GetThisAndChildIds(id.Value);

            return(View(new CategoryViewModel
            {
                Category = category,
                Products = db.Products.Where(p => ids.Contains(p.CategoryId)),
                ParentHierarchy = categoryCache.GetHierarchy(category.CategoryId),
                Children = category.Children
            }));
        }