Exemple #1
0
        public async Task <IActionResult> Get([FromQuery] string uuid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var directorySeparator = Path.DirectorySeparatorChar.ToString();
            var pathToFile         = _env.WebRootPath
                                     + directorySeparator
                                     + "resources"
                                     + directorySeparator
                                     + "CFDI.xml";

            Repository repository = new Repository();

            using (StreamReader sourceReader = System.IO.File.OpenText(pathToFile))
            {
                string rawXml = await sourceReader.ReadToEndAsync();

                if (!string.IsNullOrWhiteSpace(rawXml))
                {
                    var          cfdiJson = Transform.TransformToJson(rawXml);
                    BsonDocument document = _loaderInfo.LoadInfo(cfdiJson);
                    await repository.InsertAsync(document);

                    return(Ok(cfdiJson));
                }
            }

            return(NotFound("No se encontró el archivo especificado"));
        }
Exemple #2
0
        public BsonDocument LoadInfo(JObject cfdiObject)
        {
            _cfdiLoader.LoadInfo(cfdiObject);

            return(BsonSerializer.Deserialize <BsonDocument>(cfdiObject.ToString()));
        }