ZUGFeRDRESTService: HttpPost-Parameter anders abfragen. Es ist immer nur ein Parameter möglich

This commit is contained in:
2026-03-17 11:29:03 +01:00
parent 64ae4e9c76
commit 25e0eddfdb

View File

@@ -9,6 +9,7 @@ using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using static DigitalData.Modules.Interfaces.Exceptions;
@@ -209,36 +210,54 @@ namespace ZUGFeRDRESTService.Controllers
/// <param name="user_id">This is the email address which the user supplied</param>
/// <param name="language_id">This is language code which the user supplied (en-US, de-DE)</param>
[HttpPost]
public ValidationResponse Post(IFormFile file, string user_id, string language_id = null)
//public ValidationResponse Post(IFormFile file, StringContent user_id, StringContent language_id = null)
public ValidationResponse Post(IFormCollection collection)
{
_logger.Info("Start processing request to ValidationController");
ZugferdResult oZugferdResult = null;
CheckPropertyValuesResult oPropertyResult = new CheckPropertyValuesResult();
if (!string.IsNullOrEmpty(user_id))
var oUserId = string.Empty; // user_id == null ? string.Empty : user_id.ToString();
var oLanguageId = GERMAN; // language_id == null ? GERMAN : language_id.ToString();
IFormFile file = collection.Files[0];
foreach (var keyItem in collection.Keys)
{
_logger.Info("UserID set to [{0}].", user_id);
if (keyItem == "user_id")
{
oUserId = collection[keyItem];
}
else if (keyItem == "language_id")
{
oLanguageId = collection[keyItem];
}
}
if (!string.IsNullOrEmpty(oUserId))
{
_logger.Info("UserID set to [{0}].", oUserId);
}
else
{
_logger.Info("UserID is empty!");
}
if (string.IsNullOrEmpty(language_id))
if (string.IsNullOrEmpty(oLanguageId))
{
_logger.Info("Language code was empty. Set to default 'de-DE'");
// DEFAULT-Sprache = Deutsch de-DE
_UserLanguageCode = GERMAN;
}
else if (_AllowedLanguageCodes.Contains(language_id))
else if (_AllowedLanguageCodes.Contains(oLanguageId))
{
_logger.Info("Language code is allowed. Set to [{0}].", language_id);
_UserLanguageCode = language_id;
_logger.Info("Language code is allowed. Set to [{0}].", oLanguageId);
_UserLanguageCode = oLanguageId;
}
else
{
_logger.Info("Language code was unknown: [{0}]. Set to default 'de-DE'", language_id);
_logger.Info("Language code was unknown: [{0}]. Set to default 'de-DE'", oLanguageId);
_UserLanguageCode = GERMAN;
}