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))); }
public ActionResult <Category> Get(int id) { Category item = _repo.Find(id); if (item == null) { return(NotFound()); } return(Ok(item)); }
public IActionResult Get(int id) { var item = _categoryRepo.Find(id); if (item == null) { return(NotFound()); } return(Json(item)); }