Files
monorepo/LCU.Api.Internal.CoreApiWrapper/LCU.Api.Internal.CoreApiWrapper/Controllers/IndividualController.cs
T
2026-03-31 14:32:23 -05:00

45 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Serilog;
using LCU.Api.Internal.CoreApiWrapper.Services;
namespace LCU.Api.Internal.CoreApiWrapper.Controllers
{
[ApiController]
[Route("api/core/individuals")]
public class IndividualController : ControllerBase
{
private readonly IIndividualService _individualService;
public IndividualController(IIndividualService individualService)
{
_individualService = individualService;
}
[HttpGet()]
[ProducesResponseType(201)]
[ProducesResponseType(typeof(List<string>), 400)]
[ProducesResponseType(500)]
public IActionResult GetIndividual(string userId)
{
if (string.IsNullOrWhiteSpace(userId))
{
Log.Error("Request for invalid user id {0}", userId);
return BadRequest("User Id must not be null or empty");
}
try
{
var result = _individualService.GetIndividualByUserId(userId).Result;
return Ok(result);
}
catch (Exception ex)
{
Log.Error(ex, "Error getting individual.");
return BadRequest(ex.Message);
}
}
}
}