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); }
public void Registrar(dto.Token push) { dapperHelper .ResetParameter() .AddParameter("_usuarioId", push.UsuarioId) .AddParameter("_tipo", (int)push.Tipo) .AddParameter("_valor", push.Valor) .Insert("token_registrar"); }
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"); } }
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); }