From 6d6a4022440ecc2cd1a9173dcafd1261773c0bda Mon Sep 17 00:00:00 2001 From: tschumpr Date: Wed, 8 May 2024 10:50:36 +0200 Subject: [PATCH] Add custom properties --- src/Geopilot.Api/Context.cs | 2 ++ src/Geopilot.Api/StacServices/StacConverter.cs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/Geopilot.Api/Context.cs b/src/Geopilot.Api/Context.cs index 32436799..e81c35bb 100644 --- a/src/Geopilot.Api/Context.cs +++ b/src/Geopilot.Api/Context.cs @@ -44,6 +44,8 @@ public List DeliveriesWithIncludes .Include(d => d.DeliveryMandate) .Include(d => d.Assets) .Include(d => d.DeclaringUser) + .Include(d => d.PrecursorDelivery) + .ThenInclude(p => p.DeliveryMandate) .AsNoTracking() .ToList(); } diff --git a/src/Geopilot.Api/StacServices/StacConverter.cs b/src/Geopilot.Api/StacServices/StacConverter.cs index 8d3121f5..938a29d2 100644 --- a/src/Geopilot.Api/StacServices/StacConverter.cs +++ b/src/Geopilot.Api/StacServices/StacConverter.cs @@ -6,6 +6,7 @@ using Stac.Api.Interfaces; using Stac.Api.WebApi.Services; using Stac.Collection; +using System.Globalization; namespace Geopilot.Api.StacServices; @@ -90,6 +91,13 @@ public StacItem ToStacItem(Delivery delivery) DateTime = new TimeBlock(delivery.Date), }; + item.Properties.Add("Teilabgabe", delivery.Partial ? "Ja" : "Nein"); + item.Properties.Add("Abgegeben durch", delivery.DeclaringUser.FullName); + if (delivery.PrecursorDelivery != null) + { + item.Properties.Add("Vorgängerversion", delivery.PrecursorDelivery.Date.ToString("d.M.yyyy, H:mm:ss 'UTC'", CultureInfo.InvariantCulture)); + } + var stacApiContext = StacApiContextFactory.Create(); var assets = delivery.Assets.Select(file => ToStacAsset(file, item, stacApiContext.BaseUri)).ToDictionary(asset => asset.Title); item.Assets.AddRange(assets);