using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ROLAC.API.Services;
namespace ROLAC.API.Controllers;
[ApiController]
[Route("api/meal-attendance")]
public class MealAttendanceController : ControllerBase
{
private readonly IMealAttendanceService _svc;
public MealAttendanceController(IMealAttendanceService svc) => _svc = svc;
/// Today's live counts. Public — feeds the volunteer counter page on first load.
[HttpGet("today")]
[AllowAnonymous]
public async Task GetToday()
=> Ok(await _svc.GetOrCreateAsync(_svc.ServiceDay));
/// Daily counts within a date range, for the back-office dashboard chart.
[HttpGet]
[Authorize]
public async Task GetRange([FromQuery] DateOnly from, [FromQuery] DateOnly to)
=> Ok(await _svc.GetRangeAsync(from, to));
}