Sky.Net/API/Controllers/ProductsController.cs
2022-05-09 17:07:59 -07:00

31 lines
751 B
C#

using Core.Entities;
using Microsoft.AspNetCore.Mvc;
using Core.Interfaces;
namespace API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase
{
private readonly iProductRepository _repo;
public ProductsController(iProductRepository repo)
{
_repo = repo;
}
[HttpGet]
public async Task<ActionResult<List<Product>>> GetProducts()
{
var products = await _repo.GetProductsAync();
return Ok(products);
}
[HttpGet("{id}")]
public async Task<ActionResult<Product>> GetProduct(int id)
{
return await _repo.GetProductByIdAsync(id);
}
}
}