diff --git a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs index fc98d01a..291b10e3 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs +++ b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs @@ -283,9 +283,9 @@ namespace ZUGFeRDRESTService.Controllers _UserLanguageCode = GERMAN; } - _ParserResult.WebFilename = file.FileName; - _ParserResult.WebMailAdress = oUserId; - _ParserResult.WebLanguage = _UserLanguageCode; + _ParserResult.WebFilename = file != null && !string.IsNullOrEmpty(file.FileName) ? file.FileName : string.Empty; + _ParserResult.WebMailAdress = !string.IsNullOrEmpty(oUserId) ? oUserId : string.Empty; + _ParserResult.WebLanguage = !string.IsNullOrEmpty(_UserLanguageCode) ? _UserLanguageCode : string.Empty; try { @@ -322,9 +322,9 @@ namespace ZUGFeRDRESTService.Controllers oZugferdResult.ReceiptFileType = "XML"; } - _ParserResult.XML_Specification = oZugferdResult.Specification; - _ParserResult.XML_Schema = oZugferdResult.UsedXMLSchema; - _ParserResult.XML_FileType = oZugferdResult.ReceiptFileType; + _ParserResult.XML_Specification = !string.IsNullOrEmpty(oZugferdResult.Specification) ? oZugferdResult.Specification : string.Empty; + _ParserResult.XML_Schema = !string.IsNullOrEmpty(oZugferdResult.UsedXMLSchema) ? oZugferdResult.UsedXMLSchema : string.Empty; + _ParserResult.XML_FileType = !string.IsNullOrEmpty(oZugferdResult.ReceiptFileType) ? oZugferdResult.ReceiptFileType : string.Empty; _logger.Info("Detected Specification was: [{0}]", oZugferdResult.Specification); @@ -645,9 +645,13 @@ namespace ZUGFeRDRESTService.Controllers return new Tuple(false, string.Empty); } - oParserResult.XML_InvoiceNumber = pProperties.Where(p => p.EN16931_ID == "BT-1").FirstOrDefault().Value; - oParserResult.XML_SellerTradePartyName = pProperties.Where(p => p.EN16931_ID == "BT-27").FirstOrDefault().Value; - oParserResult.XML_SellerEmailAdress = pProperties.Where(p => p.EN16931_ID == "BT-34").FirstOrDefault().Value; + _logger.Debug("Collecting history data"); + var bt1Item = pProperties.Where(p => p.EN16931_ID == "BT-1").FirstOrDefault(); + oParserResult.XML_InvoiceNumber = bt1Item != null ? bt1Item.Value : string.Empty; + var bt27Item = pProperties.Where(p => p.EN16931_ID == "BT-27").FirstOrDefault(); + oParserResult.XML_SellerTradePartyName = bt27Item != null ? bt27Item.Value : string.Empty; + var bt34Item = pProperties.Where(p => p.EN16931_ID == "BT-34").FirstOrDefault(); + oParserResult.XML_SellerEmailAdress = bt34Item != null ? bt34Item.Value : string.Empty; _logger.Debug("Calling validation prodecure."); try