ASP.NET Core Controller with MVC and API actions
| public class ProductController : Controller { | |
| private readonly ProductRepository _repository; | |
| public ProductController(ProductRepository repository) { | |
| _repository = repository; | |
| } | |
| [Route("/api/Product/{id}")] | |
| public Product Get(int id) { | |
| return _repository.Get(id); | |
| } | |
| [Route("/Product")] | |
| public ActionResult Index() { | |
| var allProducts = _repository.GetAll(); | |
| return View(allProducts); | |
| } | |
| } |
This comment has been minimized.
This comment has been minimized.
|
Updated as recommended. Thx @DamianEdwards |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
DamianEdwards commentedJun 27, 2016
_repository_repositoryreadonlyProductRepository