mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Avoid deleting terms twice just getting the root terms on DeleteTaxonomy method (#7553)
This commit is contained in:
parent
30e669e83f
commit
8b343f3cfc
src/Orchard.Web/Modules/Orchard.Taxonomies/Services
@ -41,6 +41,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
|
||||
|
||||
IEnumerable<TermPart> GetTerms(int taxonomyId);
|
||||
IEnumerable<TermPart> GetRootTerms(int taxonomyId);
|
||||
int GetTermsCount(int taxonomyId);
|
||||
TermPart GetTerm(int id);
|
||||
TermPart GetTermByName(int taxonomyId, string name);
|
||||
|
@ -117,7 +117,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
_contentManager.Remove(taxonomy.ContentItem);
|
||||
|
||||
// Removing terms
|
||||
foreach (var term in GetTerms(taxonomy.Id)) {
|
||||
foreach (var term in GetRootTerms(taxonomy.Id)) {
|
||||
DeleteTerm(term);
|
||||
}
|
||||
|
||||
@ -171,6 +171,14 @@ namespace Orchard.Taxonomies.Services {
|
||||
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>()
|
||||
|
Loading…
Reference in New Issue
Block a user