- Konstantenmodell mit UserLanguages String-Array erstellen. Hinzufügen einer benutzerdefinierten Methode zum Abrufen der Eigenschaft über Name. - imlement in appsettings und confgire in Program.cs
27 lines
686 B
C#
27 lines
686 B
C#
using DigitalData.UserManager.API.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace DigitalData.UserManager.API.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class ConstantsController : ControllerBase
|
|
{
|
|
private readonly Constants _constants;
|
|
public ConstantsController(IOptions<Constants> constantsOptions)
|
|
{
|
|
_constants = constantsOptions.Value;
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult GetConstant(string? name = null)
|
|
{
|
|
if(name is null)
|
|
return Ok(_constants);
|
|
|
|
|
|
return Ok(_constants[name]);
|
|
}
|
|
}
|
|
} |