コード例 #1
0
        public async Task <string> JsonOperations(AgreementServicesRequest request)
        {
            var response = string.Empty;

            switch (request.Transformation.Operacion)
            {
            case OperationType.Consultar:
                response = await _jsonServices.GetAsync(
                    request.ServiceUri,
                    request.Transformation.IdFactura);

                break;

            case OperationType.Pagar:
                var resp = await _transformationRepository.TransformationCall(request.Transformation);

                var contenido = JObject.Parse(resp).GetValue("mensaje");
                response = await _jsonServices.PostAsync(
                    request.ServiceUri,
                    request.Transformation.IdFactura,
                    contenido.ToString());

                break;

            case OperationType.Compensar:
                response = await _jsonServices.DeleteAsync(
                    request.ServiceUri,
                    request.Transformation.IdFactura);

                break;
            }
            return(response);
        }
コード例 #2
0
        public async Task <IActionResult> SendPay([FromBody] AgreementServicesRequest request)
        {
            var response = await _agreementOperationsRepository.AgreementOperations(request);

            if (request.Transformation.Formato.Equals(FormatsType.Json))
            {
                return(Content(JsonConvert.SerializeObject(response)));
            }
            return(Content(response.ToString(), "application/xml"));
        }
コード例 #3
0
        public async Task <object> AgreementOperations(AgreementServicesRequest request)
        {
            object response = null;

            if (request.Transformation.Formato.Equals(FormatsType.Json))
            {
                var result = await JsonOperations(request);

                response = JsonConvert.DeserializeObject <AgreementJsonResponse>(result);
            }
            else if (request.Transformation.Formato.Equals(FormatsType.Xml))
            {
                var result = await XmlOperations(request);

                XDocument doc = XDocument.Parse(result);
                response = doc;
            }

            return(response);
        }