33 lines
858 B
C#
33 lines
858 B
C#
using Events.WebAPI.Contract.DTOs;
|
|
using Events.Auth;
|
|
using Events.WebAPI.Contract.LookupQueries;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Events.WebAPI.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("[controller]/[action]")]
|
|
public class LookupController(IMediator mediator) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
public async Task<ActionResult<List<IdName<string>>>> Countries(string? text)
|
|
{
|
|
var countries = await mediator.Send(new LookupCountryQuery { Text = text });
|
|
return countries;
|
|
}
|
|
|
|
[Authorize(Policy = nameof(Policies.ReadData))]
|
|
[HttpGet]
|
|
public async Task<ActionResult<List<IdName<int>>>> People(string? text, string? countryCode)
|
|
{
|
|
var people = await mediator.Send(new LookupPeopleQuery
|
|
{
|
|
Text = text,
|
|
CountryCode = countryCode
|
|
});
|
|
return people;
|
|
}
|
|
}
|