From 6aff06b3f526401544a4e78f79d10f01d14cbea2 Mon Sep 17 00:00:00 2001 From: Jonas Bach <69851288+JonasABach@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:12:28 +0200 Subject: [PATCH] Update api.csproj (#1319) * Update api.csproj * Update CollectionUtilities.cs * format --- backend/api/Dtos/STEAProjectDtoBuilder.cs | 4 +--- backend/api/Dtos/TimeSeries/TimeSeriesDto.cs | 1 + backend/api/Helpers/CollectionUtilities.cs | 14 ++++++++++++ backend/api/Program.cs | 2 +- backend/api/api.csproj | 23 ++++++++++---------- 5 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 backend/api/Helpers/CollectionUtilities.cs diff --git a/backend/api/Dtos/STEAProjectDtoBuilder.cs b/backend/api/Dtos/STEAProjectDtoBuilder.cs index 3ae1e5d87..4e8a94072 100644 --- a/backend/api/Dtos/STEAProjectDtoBuilder.cs +++ b/backend/api/Dtos/STEAProjectDtoBuilder.cs @@ -1,8 +1,6 @@ using api.Dtos; - -using Microsoft.IdentityModel.Tokens; - +using api.Helpers; namespace api.Adapters; public static class STEAProjectDtoBuilder diff --git a/backend/api/Dtos/TimeSeries/TimeSeriesDto.cs b/backend/api/Dtos/TimeSeries/TimeSeriesDto.cs index cb7a46cb0..b783ff294 100644 --- a/backend/api/Dtos/TimeSeries/TimeSeriesDto.cs +++ b/backend/api/Dtos/TimeSeries/TimeSeriesDto.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations; +using api.Helpers; using api.Models; using Microsoft.IdentityModel.Tokens; diff --git a/backend/api/Helpers/CollectionUtilities.cs b/backend/api/Helpers/CollectionUtilities.cs new file mode 100644 index 000000000..728394fdf --- /dev/null +++ b/backend/api/Helpers/CollectionUtilities.cs @@ -0,0 +1,14 @@ +namespace api.Helpers +{ + public static class CollectionUtilities + { + public static bool IsNullOrEmpty(this IEnumerable enumerable) + { + if (enumerable != null) + { + return !enumerable.Any(); + } + return true; + } + } +} diff --git a/backend/api/Program.cs b/backend/api/Program.cs index a62ad9e09..c10f67397 100644 --- a/backend/api/Program.cs +++ b/backend/api/Program.cs @@ -140,7 +140,7 @@ options.UseDefaultEndpointResolver(fusionEnvironment); options.UseDefaultTokenProvider(opts => { - opts.ClientId = config["AzureAd:ClientId"]; + opts.ClientId = config["AzureAd:ClientId"] ?? throw new ArgumentNullException("AzureAd:ClientId"); opts.ClientSecret = config["AzureAd:ClientSecret"]; }); options.AddFusionRoles(); diff --git a/backend/api/api.csproj b/backend/api/api.csproj index 4329e9a4f..90b41cd84 100644 --- a/backend/api/api.csproj +++ b/backend/api/api.csproj @@ -25,10 +25,11 @@ - - + + + @@ -41,14 +42,14 @@ - - - - - - - - - + + + + + + + + +