32 lines
726 B
C#
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));
|
|
}
|
|
} |