using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc; using ListmonkIntegration.Services; namespace ListmonkIntegration.Pages.api { [IgnoreAntiforgeryToken] public class ListsModel : PageModel { private readonly IListmonkService _listmonkService; private readonly ILogger _logger; public ListsModel(IListmonkService listmonkService, ILogger logger) { _listmonkService = listmonkService; _logger = logger; } public async Task OnGetAttributesAsync(int id) { try { _logger.LogInformation($"API: Getting attributes for list {id}"); var attributes = await _listmonkService.GetListAttributesAsync(id); _logger.LogInformation($"API: Found {attributes.Count} attributes"); return new JsonResult(attributes); } catch (Exception ex) { _logger.LogError(ex, "Error getting attributes"); return new JsonResult(new List()) { StatusCode = 500 }; } } } }