Fixed broken TaxonomyService due to bad merge.

This commit is contained in:
Sipke Schoorstra
2015-03-06 09:20:16 +01:00
parent 6173844445
commit 439046c298

View File

@@ -59,7 +59,7 @@ namespace Orchard.Taxonomies.Services {
}
// include the record in the query to optimize the query plan
.Query<TaxonomyPart, TaxonomyPartRecord>()
return _contentManager.Query<TaxonomyPart, TaxonomyPartRecord>()
.Join<TitlePartRecord>()
.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<TaxonomyPart>();
if (parentAsTaxonomy != null && parentAsTaxonomy != taxonomy) {
throw new ArgumentException("The parent of a term can't be a different taxonomy", "parent");
}
var parentAsTerm = parent.As<TermPart>();
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<TermPart>(taxonomy.TermTypeName);
term.Container = parent ?? taxonomy;
term.TaxonomyId = taxonomy.Id;
ProcessPath(term);
return term;
}