Initial commit
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
@page
|
||||
@model ListmonkIntegration.Pages.api.ListsModel
|
||||
@{
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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<ListsModel> _logger;
|
||||
|
||||
public ListsModel(IListmonkService listmonkService, ILogger<ListsModel> logger)
|
||||
{
|
||||
_listmonkService = listmonkService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> 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<string>()) { StatusCode = 500 };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user