Skip to content

Commit

Permalink
Avoid deleting terms twice just getting the root terms on DeleteTaxon…
Browse files Browse the repository at this point in the history
…omy method (#7553)
  • Loading branch information
jardg authored and sebastienros committed Feb 2, 2017
1 parent 30e669e commit 8b343f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public interface ITaxonomyService : IDependency {


IEnumerable<TermPart> GetTerms(int taxonomyId);
IEnumerable<TermPart> GetRootTerms(int taxonomyId);
int GetTermsCount(int taxonomyId);
TermPart GetTerm(int id);
TermPart GetTermByName(int taxonomyId, string name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void DeleteTaxonomy(TaxonomyPart taxonomy) {
_contentManager.Remove(taxonomy.ContentItem);

// Removing terms
foreach (var term in GetTerms(taxonomy.Id)) {
foreach (var term in GetRootTerms(taxonomy.Id)) {
DeleteTerm(term);
}

Expand Down Expand Up @@ -171,6 +171,14 @@ public IEnumerable<TermPart> GetTerms(int taxonomyId) {
return TermPart.Sort(result);
}

public IEnumerable<TermPart> GetRootTerms(int taxonomyId) {
var result = _contentManager.Query<TermPart, TermPartRecord>()
.Where(x => x.TaxonomyId == taxonomyId && x.Path == "/")
.List();

return TermPart.Sort(result);
}

public TermPart GetTermByPath(string path) {
return _contentManager.Query<TermPart, TermPartRecord>()
.Join<AutoroutePartRecord>()
Expand Down

0 comments on commit 8b343f3

Please sign in to comment.