Skip to content

Commit 9a79cc8

Browse files
committed
Integrate new Topic.IsNew property
This is just a shorthand for `Topic.Id < 0`, but it is more semantically meaningful and intuitive to read.
1 parent 3f1d3c6 commit 9a79cc8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

OnTopic.Editor.AspNetCore/Controllers/EditorController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ public async Task<IActionResult> Import(IFormFile jsonFile, [Bind(Prefix = "Impo
710710
/*------------------------------------------------------------------------------------------------------------------------
711711
| INDEX TOPICS IN SCOPE
712712
\-----------------------------------------------------------------------------------------------------------------------*/
713-
var topics = target.FindAll(t => t.Id >= 0).ToList();
713+
var topics = target.FindAll(t => !t.IsNew).ToList();
714714

715715
/*------------------------------------------------------------------------------------------------------------------------
716716
| INITIAL IMPORT
@@ -725,7 +725,7 @@ public async Task<IActionResult> Import(IFormFile jsonFile, [Bind(Prefix = "Impo
725725
| removed topics during a recursive save and, therefore, the deletions aren't persited to the database. To mitigate this,
726726
| we evaluate the topic graph after the save, and then delete any orphans.
727727
\-----------------------------------------------------------------------------------------------------------------------*/
728-
var unmatchedTopics = topics.Except(target.FindAll(t => t.Id >= 0));
728+
var unmatchedTopics = topics.Except(target.FindAll(t => !t.IsNew));
729729

730730
foreach (var unmatchedTopic in unmatchedTopics) {
731731
TopicRepository.Delete(unmatchedTopic);
@@ -739,7 +739,7 @@ public async Task<IActionResult> Import(IFormFile jsonFile, [Bind(Prefix = "Impo
739739
| Otherwise, Save() will generate an error since the parent ID won't be found.
740740
\-----------------------------------------------------------------------------------------------------------------------*/
741741
var saveRoot = target;
742-
if (target.Parent.Id < 0) {
742+
if (target.Parent.IsNew) {
743743
saveRoot = target.Parent;
744744
}
745745

0 commit comments

Comments
 (0)