use coalesce condition

This commit is contained in:
Florian Förster 2025-04-09 07:41:28 +02:00
parent a07907b33c
commit 95f958c29e

View File

@ -42,9 +42,7 @@ namespace dopt.DeltaBarth
{ {
pyJson = pyModPipeline.pipeline_sales_forecast_dummy(firmaId, buchungsDatum); pyJson = pyModPipeline.pipeline_sales_forecast_dummy(firmaId, buchungsDatum);
} }
var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson); var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python");
if (parsed == null) { throw new PythonParsingException("Could not correctly parse object from Python"); }
return parsed; return parsed;
} }
public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(int? firmaId, DateTime? buchungsDatum) public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(int? firmaId, DateTime? buchungsDatum)
@ -55,9 +53,7 @@ namespace dopt.DeltaBarth
{ {
pyJson = pyModPipeline.pipeline_sales_forecast(firmaId, buchungsDatum); pyJson = pyModPipeline.pipeline_sales_forecast(firmaId, buchungsDatum);
} }
var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson); var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python");
if (parsed == null) { throw new PythonParsingException("Could not correctly parse object from Python"); }
return parsed; return parsed;
} }
protected void Setup(string datenPfad, string basisApiUrl) protected void Setup(string datenPfad, string basisApiUrl)
@ -98,9 +94,7 @@ namespace dopt.DeltaBarth
} }
DataObjects.Credentials? parsed = JsonSerializer.Deserialize<DataObjects.Credentials>(pyJson); DataObjects.Credentials? parsed = JsonSerializer.Deserialize<DataObjects.Credentials>(pyJson);
if (parsed == null) { throw new PythonParsingException("Could not correctly parse object from Python"); } return parsed ?? throw new PythonParsingException("Could not correctly parse object from Python");
return parsed;
} }
} }
} }