Example #1
0
        public adduohelper.ResponseEnvelope Registrar(dto.Token token)
        {
            var response = new adduohelper.ResponseEnvelope();

            try
            {
                ValidarParaRegistrar(token);

                repositorio.Registrar(token);


                response.HttpStatusCode = HttpStatusCode.Created;
            }
            catch (ArgumentException a)
            {
                response.Error.Exception = a;
                response.HttpStatusCode  = HttpStatusCode.BadRequest;
            }
            catch
            {
                // ##TODO LOG
                response.HttpStatusCode = HttpStatusCode.InternalServerError;
            }

            return(response);
        }
Example #2
0
 public void Registrar(dto.Token push)
 {
     dapperHelper
     .ResetParameter()
     .AddParameter("_usuarioId", push.UsuarioId)
     .AddParameter("_tipo", (int)push.Tipo)
     .AddParameter("_valor", push.Valor)
     .Insert("token_registrar");
 }
Example #3
0
 public void ValidarParaRegistrar(dto.Token token)
 {
     if (string.IsNullOrEmpty(token.Valor))
     {
         throw new ArgumentException("Valor inválido", "Valor");
     }
     else if (token.UsuarioId.Equals(Guid.Empty))
     {
         throw new ArgumentException("UsuarioId inválido", "UsuarioId");
     }
 }
Example #4
0
        public dto.Token Request(TokenRequest request)
        {
            var dto = new dto.Token
            {
                Valor     = request.Valor,
                UsuarioId = Guid.Parse(request.UsuarioId),
                Tipo      = (TipoTokenEnum)request.Tipo
            };

            return(dto);
        }