mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-24 18:25:04 +08:00
Avoid deleting terms twice just getting the root terms on DeleteTaxonomy method (#7553)
This commit is contained in:
committed by
Sébastien Ros
parent
30e669e83f
commit
8b343f3cfc
@@ -41,6 +41,7 @@ namespace Orchard.Taxonomies.Services {
|
|||||||
|
|
||||||
|
|
||||||
IEnumerable<TermPart> GetTerms(int taxonomyId);
|
IEnumerable<TermPart> GetTerms(int taxonomyId);
|
||||||
|
IEnumerable<TermPart> GetRootTerms(int taxonomyId);
|
||||||
int GetTermsCount(int taxonomyId);
|
int GetTermsCount(int taxonomyId);
|
||||||
TermPart GetTerm(int id);
|
TermPart GetTerm(int id);
|
||||||
TermPart GetTermByName(int taxonomyId, string name);
|
TermPart GetTermByName(int taxonomyId, string name);
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ namespace Orchard.Taxonomies.Services {
|
|||||||
_contentManager.Remove(taxonomy.ContentItem);
|
_contentManager.Remove(taxonomy.ContentItem);
|
||||||
|
|
||||||
// Removing terms
|
// Removing terms
|
||||||
foreach (var term in GetTerms(taxonomy.Id)) {
|
foreach (var term in GetRootTerms(taxonomy.Id)) {
|
||||||
DeleteTerm(term);
|
DeleteTerm(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +171,14 @@ namespace Orchard.Taxonomies.Services {
|
|||||||
return TermPart.Sort(result);
|
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) {
|
public TermPart GetTermByPath(string path) {
|
||||||
return _contentManager.Query<TermPart, TermPartRecord>()
|
return _contentManager.Query<TermPart, TermPartRecord>()
|
||||||
.Join<AutoroutePartRecord>()
|
.Join<AutoroutePartRecord>()
|
||||||
|
|||||||
Reference in New Issue
Block a user