From 439046c298bc59d2c5b31d6bb960846e8e8e140e Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 6 Mar 2015 09:20:16 +0100 Subject: [PATCH] Fixed broken TaxonomyService due to bad merge. --- .../Services/TaxonomyService.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.Taxonomies/Services/TaxonomyService.cs b/src/Orchard.Web/Modules/Orchard.Taxonomies/Services/TaxonomyService.cs index d478883af..a442baa9d 100644 --- a/src/Orchard.Web/Modules/Orchard.Taxonomies/Services/TaxonomyService.cs +++ b/src/Orchard.Web/Modules/Orchard.Taxonomies/Services/TaxonomyService.cs @@ -59,7 +59,7 @@ namespace Orchard.Taxonomies.Services { } // include the record in the query to optimize the query plan - .Query() + return _contentManager.Query() .Join() .Where(r => r.Title == name) .List() @@ -122,8 +122,30 @@ namespace Orchard.Taxonomies.Services { } public TermPart NewTerm(TaxonomyPart taxonomy) { + return NewTerm(taxonomy, null); + } + + public TermPart NewTerm(TaxonomyPart taxonomy, IContent parent) { + if (taxonomy == null) { + throw new ArgumentNullException("taxonomy"); + } + + if (parent != null) { + var parentAsTaxonomy = parent.As(); + if (parentAsTaxonomy != null && parentAsTaxonomy != taxonomy) { + throw new ArgumentException("The parent of a term can't be a different taxonomy", "parent"); + } + + var parentAsTerm = parent.As(); + if (parentAsTerm != null && parentAsTerm.TaxonomyId != taxonomy.Id) { + throw new ArgumentException("The parent of a term can't be a from a different taxonomy", "parent"); + } + } + var term = _contentManager.New(taxonomy.TermTypeName); + term.Container = parent ?? taxonomy; term.TaxonomyId = taxonomy.Id; + ProcessPath(term); return term; }