public async Task <IActionResult> GetKeyCard() { Coordenate coordenate; try { JwtData jwt = (JwtData)RouteData.Values["jwtData"]; var type = string.IsNullOrEmpty(jwt.DocumentType) ? UserType.Personal : UserType.Empresarial; coordenate = await _authEmpresarialRepository.GetKeyCardCoordenate(type); if (string.IsNullOrEmpty(coordenate.positionNumber)) { return(Unauthorized(new FrontStatusCode(coordenate.Messages))); } } catch (Exception ex) { return(StatusCode(500, string.Format($"{Enums.GetEnumDescription(ApiMessages.DefaultError)} {ex.Message} "))); } return(Ok(new KeyCardPosition() { Position = coordenate.positionNumber })); }
public async Task <IActionResult> ValidatePersonalKeyCard(ValidateKeyCard keyCard) { try { JwtData jwt = (JwtData)RouteData.Values["jwtData"]; var type = string.IsNullOrEmpty(jwt.DocumentType) ? UserType.Personal : UserType.Empresarial; Coordenate coordenate = await _authPersonalRepository.GetKeyCardCoordenate(type); var brokerResponse = _authPersonalRepository.ValidateKeyCard(UserType.Personal, new KeyCardBase() { KeyCardCoordinate = coordenate.positionNumber, KeyCardValue = keyCard.Value, UserName = jwt.UserName }); if (string.IsNullOrEmpty(brokerResponse.validated.ToString())) { return(StatusCode(502, Enums.GetEnumDescription(ApiMessages.BrokerNoResponse))); } if (brokerResponse.validated == false) { return(BadRequest(new FrontStatusCode("Valor de la tarjéta de claves incorrecto"))); } } catch (Exception ex) { return(StatusCode(500, string.Format($"{Enums.GetEnumDescription(ApiMessages.DefaultError)} {ex.Message} "))); } await Task.CompletedTask; return(Ok()); }