mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixed broken TaxonomyService due to bad merge.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user