Created
December 29, 2019 11:55
-
-
Save merken/a813a8243d3de6c1e0ef1d2a5dc6eee1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Contract; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Logging; | |
namespace Products.API.Controllers | |
{ | |
[ApiController] | |
[Route("[controller]")] | |
public class ProductsController : ControllerBase | |
{ | |
private readonly ILogger<ProductsController> logger; | |
private readonly IProductsRepository productsRepository; | |
public ProductsController(ILogger<ProductsController> logger, IProductsRepository productsRepository) | |
{ | |
this.logger = logger; | |
this.productsRepository = productsRepository; | |
} | |
[HttpGet] | |
public Task<IEnumerable<Product>> Get() | |
{ | |
return this.productsRepository.All(); | |
} | |
[HttpGet("{id}")] | |
public Task<Product> Get(string id) | |
{ | |
return this.productsRepository.Get(int.Parse(id)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment