This commit is contained in:
2026-05-24 15:59:50 -04:00
parent 74c21ee5cc
commit 0db27bada2
282 changed files with 288 additions and 36 deletions

View File

@@ -198,7 +198,8 @@
}
// Page content is already bound by the text editor so just save
context.Update(_homePageConfiguration);
context.HomePageConfiguration.Attach(_homePageConfiguration);
context.Entry(_homePageConfiguration).State = EntityState.Modified;
await context.SaveChangesAsync();
// Clear the memory cache of the home page values
@@ -247,23 +248,43 @@
await using var context = await ContextFactory.CreateDbContextAsync();
// Attach all of the existing tags to the context
foreach (var tag in _selectedTags.Where(t => t.Id != 0))
// Attach the parent configuration first. This recursively attaches all loaded sliders and their tags as Unchanged.
context.HomePageConfiguration.Attach(_homePageConfiguration);
// Prepare the tags for the NEW entry.
// We must ensure we use tracked instances if they are already in the context from the Attach above.
List<ArtifactEntryTag> tagsToUse = new();
foreach (var tag in _selectedTags)
{
context.ArtifactEntryTags.Attach(tag);
if (tag.Id != 0)
{
var trackedTag = context.ArtifactEntryTags.Local.FirstOrDefault(t => t.Id == tag.Id);
if (trackedTag != null)
{
tagsToUse.Add(trackedTag);
}
else
{
context.ArtifactEntryTags.Attach(tag);
tagsToUse.Add(tag);
}
}
else
{
tagsToUse.Add(tag);
}
}
var newEntry = new SearchPageSliderEntry()
{
Title = _titleInputValue,
Description = _descriptionInputValue,
FilterTags = _selectedTags,
FilterTags = tagsToUse,
IsHomePageSlider = true,
HomePageConfiguration = _homePageConfiguration
};
_homePageConfiguration.SliderEntries!.Add(newEntry);
context.Update(_homePageConfiguration);
await context.SaveChangesAsync();
Snackbar.Add("Added slider", Severity.Success);