44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Http;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using Net.Business.DTO;
|
||
|
|
using Net.Business.DTO.Authenticate;
|
||
|
|
using Net.Data;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
|
||
|
|
namespace Net.Business.Services.Controllers
|
||
|
|
{
|
||
|
|
[Route("api/[controller]/[action]")]
|
||
|
|
[ApiController]
|
||
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||
|
|
[ApiExplorerSettings(GroupName = "ApiSAPWMS")]
|
||
|
|
public class AuthenticateController : ControllerBase
|
||
|
|
{
|
||
|
|
private readonly IRepositoryWrapper _repository;
|
||
|
|
public AuthenticateController(IRepositoryWrapper repository)
|
||
|
|
{
|
||
|
|
this._repository = repository;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Obtiene Token de Acceso
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="value">Parametros de filtros</param>
|
||
|
|
/// <returns>Devuelve Token de Acceso</returns>
|
||
|
|
[HttpPost]
|
||
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||
|
|
public async Task<IActionResult> Token([FromBody] Dto_AuthenticateRequest value)
|
||
|
|
{
|
||
|
|
|
||
|
|
var objectGetAll = await _repository.Authenticate.GetToken(value.RetornaModelo());
|
||
|
|
|
||
|
|
if (objectGetAll.StatusCode == -1)
|
||
|
|
{
|
||
|
|
return BadRequest(objectGetAll);
|
||
|
|
}
|
||
|
|
|
||
|
|
return Ok(objectGetAll.Data);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|