using System;
using System.Collections.Generic;
using Umbraco.Core.Models;
using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Services
{
public interface IRelationService : IService
{
///
/// Gets a by its Id
///
/// Id of the
/// A object
IRelation GetById(int id);
///
/// Gets a by its Id
///
/// Id of the
/// A object
IRelationType GetRelationTypeById(int id);
///
/// Gets a by its Id
///
/// Id of the
/// A object
IRelationType GetRelationTypeById(Guid id);
///
/// Gets a by its Alias
///
/// Alias of the
/// A object
IRelationType GetRelationTypeByAlias(string alias);
///
/// Gets all objects
///
/// Optional array of integer ids to return relations for
/// An enumerable list of objects
IEnumerable GetAllRelations(params int[] ids);
///
/// Gets all objects by their
///
/// to retrieve Relations for
/// An enumerable list of objects
IEnumerable GetAllRelationsByRelationType(RelationType relationType);
///
/// Gets all objects by their 's Id
///
/// Id of the to retrieve Relations for
/// An enumerable list of objects
IEnumerable GetAllRelationsByRelationType(int relationTypeId);
///
/// Gets all objects
///
/// Optional array of integer ids to return relationtypes for
/// An enumerable list of objects
IEnumerable GetAllRelationTypes(params int[] ids);
///
/// Gets a list of objects by their parent Id
///
/// Id of the parent to retrieve relations for
/// An enumerable list of objects
IEnumerable GetByParentId(int id);
///
/// Gets a list of objects by their parent entity
///
/// Parent Entity to retrieve relations for
/// An enumerable list of objects
IEnumerable GetByParent(IUmbracoEntity parent);
///
/// Gets a list of objects by their parent entity
///
/// Parent Entity to retrieve relations for
/// Alias of the type of relation to retrieve
/// An enumerable list of objects
IEnumerable GetByParent(IUmbracoEntity parent, string relationTypeAlias);
///
/// Gets a list of objects by their child Id
///
/// Id of the child to retrieve relations for
/// An enumerable list of objects
IEnumerable GetByChildId(int id);
///
/// Gets a list of objects by their child Entity
///
/// Child Entity to retrieve relations for
/// An enumerable list of objects
IEnumerable GetByChild(IUmbracoEntity child);
///
/// Gets a list of objects by their child Entity
///
/// Child Entity to retrieve relations for
/// Alias of the type of relation to retrieve
/// An enumerable list of objects
IEnumerable GetByChild(IUmbracoEntity child, string relationTypeAlias);
///
/// Gets a list of objects by their child or parent Id.
/// Using this method will get you all relations regards of it being a child or parent relation.
///
/// Id of the child or parent to retrieve relations for
/// An enumerable list of objects
IEnumerable GetByParentOrChildId(int id);
IEnumerable GetByParentOrChildId(int id, string relationTypeAlias);
///
/// Gets a list of objects by the Name of the
///
/// Name of the to retrieve Relations for
/// An enumerable list of objects
IEnumerable GetByRelationTypeName(string relationTypeName);
///
/// Gets a list of objects by the Alias of the
///
/// Alias of the to retrieve Relations for
/// An enumerable list of objects
IEnumerable GetByRelationTypeAlias(string relationTypeAlias);
///
/// Gets a list of objects by the Id of the
///
/// Id of the to retrieve Relations for
/// An enumerable list of objects
IEnumerable GetByRelationTypeId(int relationTypeId);
///
/// Gets the Child object from a Relation as an
///
/// Relation to retrieve child object from
/// Optional bool to load the complete object graph when set to False
/// An
IUmbracoEntity GetChildEntityFromRelation(IRelation relation, bool loadBaseType = false);
///
/// Gets the Parent object from a Relation as an
///
/// Relation to retrieve parent object from
/// Optional bool to load the complete object graph when set to False
/// An
IUmbracoEntity GetParentEntityFromRelation(IRelation relation, bool loadBaseType = false);
///
/// Gets the Parent and Child objects from a Relation as a "/> with .
///
/// Relation to retrieve parent and child object from
/// Optional bool to load the complete object graph when set to False
/// Returns a Tuple with Parent (item1) and Child (item2)
Tuple GetEntitiesFromRelation(IRelation relation, bool loadBaseType = false);
///
/// Gets the Child objects from a list of Relations as a list of objects.
///
/// List of relations to retrieve child objects from
/// Optional bool to load the complete object graph when set to False
/// An enumerable list of
IEnumerable GetChildEntitiesFromRelations(IEnumerable relations, bool loadBaseType = false);
///
/// Gets the Parent objects from a list of Relations as a list of objects.
///
/// List of relations to retrieve parent objects from
/// Optional bool to load the complete object graph when set to False
/// An enumerable list of
IEnumerable GetParentEntitiesFromRelations(IEnumerable relations,
bool loadBaseType = false);
///
/// Gets the Parent and Child objects from a list of Relations as a list of objects.
///
/// List of relations to retrieve parent and child objects from
/// Optional bool to load the complete object graph when set to False
/// An enumerable list of with
IEnumerable> GetEntitiesFromRelations(
IEnumerable relations,
bool loadBaseType = false);
///
/// Relates two objects that are based on the interface.
///
/// Parent entity
/// Child entity
/// The type of relation to create
/// The created
IRelation Relate(IUmbracoEntity parent, IUmbracoEntity child, IRelationType relationType);
///
/// Relates two objects that are based on the interface.
///
/// Parent entity
/// Child entity
/// Alias of the type of relation to create
/// The created
IRelation Relate(IUmbracoEntity parent, IUmbracoEntity child, string relationTypeAlias);
///
/// Checks whether any relations exists for the passed in .
///
/// to check for relations
/// Returns True if any relations exists for the given , otherwise False
bool HasRelations(IRelationType relationType);
///
/// Checks whether any relations exists for the passed in Id.
///
/// Id of an object to check relations for
/// Returns True if any relations exists with the given Id, otherwise False
bool IsRelated(int id);
///
/// Checks whether two items are related
///
/// Id of the Parent relation
/// Id of the Child relation
/// Returns True if any relations exists with the given Ids, otherwise False
bool AreRelated(int parentId, int childId);
///
/// Checks whether two items are related
///
/// Parent entity
/// Child entity
/// Returns True if any relations exist between the entities, otherwise False
bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child);
///
/// Checks whether two items are related
///
/// Parent entity
/// Child entity
/// Alias of the type of relation to create
/// Returns True if any relations exist between the entities, otherwise False
bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child, string relationTypeAlias);
///
/// Checks whether two items are related
///
/// Id of the Parent relation
/// Id of the Child relation
/// Alias of the type of relation to create
/// Returns True if any relations exist between the entities, otherwise False
bool AreRelated(int parentId, int childId, string relationTypeAlias);
///
/// Saves a
///
/// Relation to save
void Save(IRelation relation);
///
/// Saves a
///
/// RelationType to Save
void Save(IRelationType relationType);
///
/// Deletes a
///
/// Relation to Delete
void Delete(IRelation relation);
///
/// Deletes a
///
/// RelationType to Delete
void Delete(IRelationType relationType);
///
/// Deletes all objects based on the passed in
///
/// to Delete Relations for
void DeleteRelationsOfType(IRelationType relationType);
}
}