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 TokenResponse Response(adduohelper.ResponseEnvelope envelope) { var response = new TokenResponse { HttpStatusCode = (int)envelope.HttpStatusCode }; return(response); }
private static adduohelper.ResponseEnvelope CriarEnvelope(HttpResponseMessage response) { var envelope = new adduohelper.ResponseEnvelope(); envelope.HttpStatusCode = response.StatusCode; if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError) { envelope.Error.Messages.Add(response.ReasonPhrase); } return(envelope); }
public IActionResult ResultFactory(adduohelper.ResponseEnvelope response) { IActionResult result; if (response.HttpStatusCode == System.Net.HttpStatusCode.InternalServerError) { var message = response.Error.Messages.Any() ? response.Error.Messages.First() : string.Empty; result = StatusCode((int)response.HttpStatusCode, message); } else { result = StatusCode((int)response.HttpStatusCode, response); } return(result); }