From 95f958c29e7db4284527f2e9cfd95ceebf73b83d Mon Sep 17 00:00:00 2001 From: foefl Date: Wed, 9 Apr 2025 07:41:28 +0200 Subject: [PATCH] use coalesce condition --- dopt.DeltaBarth/Plugin.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/dopt.DeltaBarth/Plugin.cs b/dopt.DeltaBarth/Plugin.cs index 1a736ea..1a20dd2 100644 --- a/dopt.DeltaBarth/Plugin.cs +++ b/dopt.DeltaBarth/Plugin.cs @@ -42,9 +42,7 @@ namespace dopt.DeltaBarth { pyJson = pyModPipeline.pipeline_sales_forecast_dummy(firmaId, buchungsDatum); } - var parsed = JsonSerializer.Deserialize(pyJson); - if (parsed == null) { throw new PythonParsingException("Could not correctly parse object from Python"); } - + var parsed = JsonSerializer.Deserialize(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python"); return parsed; } public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(int? firmaId, DateTime? buchungsDatum) @@ -55,9 +53,7 @@ namespace dopt.DeltaBarth { pyJson = pyModPipeline.pipeline_sales_forecast(firmaId, buchungsDatum); } - var parsed = JsonSerializer.Deserialize(pyJson); - if (parsed == null) { throw new PythonParsingException("Could not correctly parse object from Python"); } - + var parsed = JsonSerializer.Deserialize(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python"); return parsed; } protected void Setup(string datenPfad, string basisApiUrl) @@ -98,9 +94,7 @@ namespace dopt.DeltaBarth } DataObjects.Credentials? parsed = JsonSerializer.Deserialize(pyJson); - if (parsed == null) { throw new PythonParsingException("Could not correctly parse object from Python"); } - - return parsed; + return parsed ?? throw new PythonParsingException("Could not correctly parse object from Python"); } } }