YPS-Beer/backend/YPS.Beer/Controllers/BeerController.cs
2023-12-07 00:20:59 +00:00

32 lines
726 B
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using YPS.Beer.Services;
namespace YPS.Beer.Controllers;
[Authorize]
[ApiController]
[Route("[controller]")]
public class BeerController : ControllerBase
{
private readonly IPunkService _punkService;
public BeerController(IPunkService punkService)
{
_punkService = punkService;
}
[HttpGet("/{id}")]
public async Task<IActionResult> GetBeer(int id)
{
var beer = await _punkService.GetBeer(id);
return beer is null ? NotFound() : Ok(beer);
}
[HttpGet]
public async Task<IActionResult> SearchBeer(string search)
{
return Ok(await _punkService.FindBeers(search));
}
}