From 5d72e8678f47fcdf563e3b641c26ad917be20960 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 16 Jan 2018 09:51:04 +1000 Subject: [PATCH] Ensure non-templated entities can still be created through their resource group's Items link --- .../ResourceGroups/EntityResourceGroup.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Seq.Api/ResourceGroups/EntityResourceGroup.cs b/src/Seq.Api/ResourceGroups/EntityResourceGroup.cs index e1e51da..6bee541 100644 --- a/src/Seq.Api/ResourceGroups/EntityResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/EntityResourceGroup.cs @@ -13,9 +13,21 @@ internal EntityResourceGroup(string name, ISeqConnection connection) : base(name protected async Task GroupCreateAsync(TEntity entity, IDictionary parameters = null) where TEntity : ILinked { - var link = entity.Links.ContainsKey("Create") ? "Create" : "Items"; - var group = await LoadGroupAsync().ConfigureAwait(false); - return await Client.PostAsync(group, link, entity, parameters).ConfigureAwait(false); + ILinked resource; + string link; + + if (entity.Links.ContainsKey("Create")) + { + resource = entity; + link = "Create"; + } + else + { + resource = await LoadGroupAsync().ConfigureAwait(false); + link = "Items"; + } + + return await Client.PostAsync(resource, link, entity, parameters).ConfigureAwait(false); } } -} \ No newline at end of file +}