Skip to content

Commit

Permalink
Fixed orphaned page collection.
Browse files Browse the repository at this point in the history
  • Loading branch information
NTDLS committed Apr 28, 2023
1 parent bf09e45 commit 477e090
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ TightWiki/obj/
CreateDatabaseSeeds/bin/

CreateDatabaseSeeds/obj/

TightWiki.Shared/Properties/PublishProfiles/
23 changes: 21 additions & 2 deletions TightWiki.Shared/Models/Data/NameNav.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
namespace TightWiki.Shared.Models.Data
using System;
using System.Linq;

namespace TightWiki.Shared.Models.Data
{
public class NameNav
{
public string Name { get; set; }
public string Namespace { get; set; }
public string Navigation { get; set; }

public NameNav()
Expand All @@ -11,7 +15,22 @@ public NameNav()

public NameNav(string name, string navigation)
{
Name = name;
var parts = name.Split("::");

if (parts.Count() == 1)
{
Name = parts[0]?.Trim();
}
else if (parts.Count() == 2)
{
Namespace = parts[0]?.Trim();
Name = parts[1]?.Trim();
}
else
{
throw new Exception($"Invalid page name {name}");
}

Navigation = navigation;
}
}
Expand Down
3 changes: 1 addition & 2 deletions TightWiki.Shared/Repository/Extensions/PageRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ public static void UpdateSinglePageReference(string pageNavigation)
public static void UpdatePageReferences(int pageId, List<NameNav> referencesPageNavigations)
{
using var handler = new SqlConnectionHandler();
var array = string.Join("\n", referencesPageNavigations.Select(o => $"{o.Navigation}/{o.Name}"));

var param = new
{
PageId = pageId,
@ReferencesPageNavigations = array
References = referencesPageNavigations.ToDataTable()
};

handler.Connection.Execute("UpdatePageReferences",
Expand Down
2 changes: 1 addition & 1 deletion TightWiki/Controllers/PageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public ActionResult Display(string pageNavigation, int? pageRevision)
context.SetPageId(page.Id, pageRevision);
ViewBag.Config.Title = page.Title;

bool allowCache = false;
bool allowCache = true;

if (allowCache)
{
Expand Down

0 comments on commit 477e090

Please sign in to comment.