Example #1
0
        public void ShouldGetCategory()
        {
            var category = new Category {
                CategoryName = "Foo"
            };

            _repo.Add(category);
            _repo.Find(category.Id);
        }
        public IActionResult ProductList([FromServices] ICategoryRepo categoryRepo, int id)
        {
            var cat = categoryRepo.Find(id);

            ViewBag.Title        = cat?.CategoryName;
            ViewBag.Header       = cat?.CategoryName;
            ViewBag.ShowCategory = false;
            ViewBag.Featured     = false;
            return(View(_productRepo.GetProductsForCategory(id)));
        }
Example #3
0
        public ActionResult <Category> Get(int id)
        {
            Category item = _repo.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(Ok(item));
        }
Example #4
0
        public IActionResult Get(int id)
        {
            var item = _categoryRepo.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(Json(item));
        }