コード例 #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);
        }
コード例 #2
0
        public TokenResponse Response(adduohelper.ResponseEnvelope envelope)
        {
            var response = new TokenResponse
            {
                HttpStatusCode = (int)envelope.HttpStatusCode
            };

            return(response);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }