using Microsoft.AspNetCore.Mvc;
using Nexus.Api.Services;

namespace Nexus.Api.Controllers;

[ApiController]
[Route("api/v1/incidents")]
public class IncidentsController(IIncidentService incidentService) : ControllerBase
{
    [HttpGet]
    public async Task<IResult> GetAll()
        => Results.Ok(await incidentService.GetAllAsync());

    [HttpGet("{name}")]
    public async Task<IResult> GetOne(string name)
    {
        var incident = await incidentService.GetByNameAsync(name);
        return incident is null ? Results.NotFound() : Results.Ok(incident);
    }
}
