using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using LCU.Api.Internal.CoreApiWrapper.Services; using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Associate; using LCU.Library.Internal.Exceptions; using Microsoft.AspNetCore.Http; using Serilog; namespace LCU.Api.Internal.CoreApiWrapper.Controllers { [ApiController] [Route("api/core/[controller]")] public class AssociateController : ControllerBase { private readonly IAssociateService _associateService; public AssociateController(IAssociateService associateService) { _associateService = associateService; } [HttpGet("GetAssociateDetailsBySsn/{taxId}")] [ProducesResponseType(201)] [ProducesResponseType(typeof(AssociateDetails), 400)] [ProducesResponseType(404)] [ProducesResponseType(500)] public async Task GetAssociateDetailsBySsn(string taxId) { try { if (string.IsNullOrWhiteSpace(taxId)) { return BadRequest("Must enter a valid taxId"); } var result = await _associateService.GetAssociateDetailsBySsn(taxId); if (result is null) { return NoContent(); } return Ok(result); } catch (ServiceException) { return StatusCode(StatusCodes.Status500InternalServerError); } catch (Exception exception) { Log.Error(exception, "Unexpected Exception"); return StatusCode(StatusCodes.Status500InternalServerError); } } } }