Avoid deleting terms twice just getting the root terms on DeleteTaxonomy method ()

This commit is contained in:
Julián Alazorza 2017-02-02 21:17:08 +01:00 committed by Sébastien Ros
parent 30e669e83f
commit 8b343f3cfc
2 changed files with 10 additions and 1 deletions
src/Orchard.Web/Modules/Orchard.Taxonomies/Services

View File

@ -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);

View File

@ -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>()