Skip to content

Commit

Permalink
Fix Taxonomy Serialization (#15615)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Sébastien Ros <[email protected]>
  • Loading branch information
MikeAlhayek and sebastienros authored Mar 28, 2024
1 parent 7e9f3ac commit 7aea7c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System.Linq;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Settings;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.Extensions.Options;
using OrchardCore.Admin;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display;
Expand Down Expand Up @@ -321,7 +319,10 @@ public async Task<IActionResult> Delete(string taxonomyContentItemId, string tax
return NotFound();
}

taxonomy.As<TaxonomyPart>().Content.Remove(taxonomyItemId);
taxonomy.Alter<TaxonomyPart>(part =>
{
part.Terms = part.Terms.Where(x => x.ContentItemId != taxonomyItemId).ToList();
});

await _session.SaveAsync(taxonomy);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ public override ContentItem Read(ref Utf8JsonReader reader, Type typeToConvert,
contentItem.Owner = reader.TokenType == JsonTokenType.String ? reader.GetString() : null;
break;
default:
if (reader.TokenType == JsonTokenType.StartObject)
if (reader.TokenType == JsonTokenType.StartObject ||
reader.TokenType == JsonTokenType.StartArray)
{
var property = JNode.Load(ref reader);
contentItem.Data.Add(propertyName, property);
contentItem.Data[propertyName] = property;
}

break;
Expand Down

0 comments on commit 7aea7c4

Please sign in to comment.