ticket-system/source/ticketAPI/api/Controllers/ScanController.cs
2024-12-05 20:27:49 -05:00

35 lines
958 B
C#

using api.Interfaces;
using Microsoft.AspNetCore.Mvc;
using models.Response;
namespace api.Controllers;
/// <summary>
/// Endpoints for Ticket Scanning
/// </summary>
/// <param name="ticketManager">Injected Ticket Manager Service</param>
[ApiController]
[Route("[controller]")]
public class ScanController(ITicketManager ticketManager) : ControllerBase
{
/// <summary>
/// Searches for a ticket with a given ticketId and validates it against the event associated with it.
/// </summary>
/// <param name="ticketId">A string representing a GUID value</param>
/// <returns>Ticket Search Result</returns>
[HttpGet]
public ActionResult<TicketSearch> Get(Guid ticketId)
{
//TODO: Protect Endpoint
try
{
var result = ticketManager.SearchTicket(ticketId);
return Ok(result);
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
}