Skip to content

Commit

Permalink
Add custom properties
Browse files Browse the repository at this point in the history
  • Loading branch information
tschumpr committed May 8, 2024
1 parent c60dd5e commit 6d6a402
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Geopilot.Api/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public List<Delivery> DeliveriesWithIncludes
.Include(d => d.DeliveryMandate)
.Include(d => d.Assets)
.Include(d => d.DeclaringUser)
.Include(d => d.PrecursorDelivery)
.ThenInclude(p => p.DeliveryMandate)

Check failure on line 48 in src/Geopilot.Api/Context.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check failure on line 48 in src/Geopilot.Api/Context.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
.AsNoTracking()
.ToList();
}
Expand Down
8 changes: 8 additions & 0 deletions src/Geopilot.Api/StacServices/StacConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Stac.Api.Interfaces;
using Stac.Api.WebApi.Services;
using Stac.Collection;
using System.Globalization;

namespace Geopilot.Api.StacServices;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6d6a402

Please sign in to comment.