Class MediaService
Represents the Media Service, which is an easy access to operations involving IMedia
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public class MediaService : ScopeRepositoryService, IMediaService, IContentServiceBase, IService, IMediaServiceOperations
Constructors
MediaService(IDatabaseUnitOfWorkProvider, RepositoryFactory, ILogger, IEventMessagesFactory, IDataTypeService, IUserService)
Declaration
public MediaService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, ILogger logger, IEventMessagesFactory eventMessagesFactory, IDataTypeService dataTypeService, IUserService userService)
Parameters
Type | Name | Description |
---|---|---|
IDatabaseUnitOfWorkProvider | provider | |
RepositoryFactory | repositoryFactory | |
ILogger | logger | |
IEventMessagesFactory | eventMessagesFactory | |
IDataTypeService | dataTypeService | |
IUserService | userService |
Methods
Count(String)
Declaration
public int Count(string contentTypeAlias = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentTypeAlias |
Returns
Type | Description |
---|---|
System.Int32 |
CountChildren(Int32, String)
Declaration
public int CountChildren(int parentId, string contentTypeAlias = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId | |
System.String | contentTypeAlias |
Returns
Type | Description |
---|---|
System.Int32 |
CountDescendants(Int32, String)
Declaration
public int CountDescendants(int parentId, string contentTypeAlias = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId | |
System.String | contentTypeAlias |
Returns
Type | Description |
---|---|
System.Int32 |
CountNotTrashed(String)
Declaration
public int CountNotTrashed(string contentTypeAlias = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentTypeAlias |
Returns
Type | Description |
---|---|
System.Int32 |
CreateMedia(String, Guid, String, Int32)
Creates an IMedia object using the alias of the IMediaType that this Media should based on.
Declaration
public IMedia CreateMedia(string name, Guid parentId, string mediaTypeAlias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the Media object |
System.Guid | parentId | Id of Parent for the new Media item |
System.String | mediaTypeAlias | Alias of the IMediaType |
System.Int32 | userId | Optional id of the user creating the media item |
Returns
Type | Description |
---|---|
IMedia | IMedia |
Remarks
Note that using this method will simply return a new IMedia without any identity as it has not yet been persisted. It is intended as a shortcut to creating new media objects that does not invoke a save operation against the database.
CreateMedia(String, Int32, String, Int32)
Creates an IMedia object using the alias of the IMediaType that this Media should based on.
Declaration
public IMedia CreateMedia(string name, int parentId, string mediaTypeAlias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the Media object |
System.Int32 | parentId | Id of Parent for the new Media item |
System.String | mediaTypeAlias | Alias of the IMediaType |
System.Int32 | userId | Optional id of the user creating the media item |
Returns
Type | Description |
---|---|
IMedia | IMedia |
Remarks
Note that using this method will simply return a new IMedia without any identity as it has not yet been persisted. It is intended as a shortcut to creating new media objects that does not invoke a save operation against the database.
CreateMedia(String, IMedia, String, Int32)
Creates an IMedia object using the alias of the IMediaType that this Media should based on.
Declaration
public IMedia CreateMedia(string name, IMedia parent, string mediaTypeAlias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the Media object |
IMedia | parent | Parent IMedia for the new Media item |
System.String | mediaTypeAlias | Alias of the IMediaType |
System.Int32 | userId | Optional id of the user creating the media item |
Returns
Type | Description |
---|---|
IMedia | IMedia |
Remarks
Note that using this method will simply return a new IMedia without any identity as it has not yet been persisted. It is intended as a shortcut to creating new media objects that does not invoke a save operation against the database.
CreateMediaWithIdentity(String, Int32, String, Int32)
Creates an IMedia object using the alias of the IMediaType that this Media should based on.
Declaration
public IMedia CreateMediaWithIdentity(string name, int parentId, string mediaTypeAlias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the Media object |
System.Int32 | parentId | Id of Parent for the new Media item |
System.String | mediaTypeAlias | Alias of the IMediaType |
System.Int32 | userId | Optional id of the user creating the media item |
Returns
Type | Description |
---|---|
IMedia | IMedia |
Remarks
This method returns an IMedia object that has been persisted to the database and therefor has an identity.
CreateMediaWithIdentity(String, IMedia, String, Int32)
Creates an IMedia object using the alias of the IMediaType that this Media should based on.
Declaration
public IMedia CreateMediaWithIdentity(string name, IMedia parent, string mediaTypeAlias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the Media object |
IMedia | parent | Parent IMedia for the new Media item |
System.String | mediaTypeAlias | Alias of the IMediaType |
System.Int32 | userId | Optional id of the user creating the media item |
Returns
Type | Description |
---|---|
IMedia | IMedia |
Remarks
This method returns an IMedia object that has been persisted to the database and therefor has an identity.
Delete(IMedia, Int32)
Permanently deletes an IMedia object as well as all of its Children.
Declaration
public void Delete(IMedia media, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IMedia | media | The IMedia to delete |
System.Int32 | userId | Id of the User deleting the Media |
Remarks
Please note that this method will completely remove the Media from the database, as well as associated media files from the file system.
DeleteMediaFile(String)
Declaration
public void DeleteMediaFile(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath |
DeleteMediaOfType(Int32, Int32)
Deletes all media of specified type. All children of deleted media is moved to Recycle Bin.
Declaration
public void DeleteMediaOfType(int mediaTypeId, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | mediaTypeId | Id of the IMediaType |
System.Int32 | userId | Optional id of the user deleting the media |
Remarks
This needs extra care and attention as its potentially a dangerous and extensive operation
DeleteMediaOfTypes(IEnumerable<Int32>, Int32)
Deletes all content of the specified types. All Descendants of deleted content that is not of these types is moved to Recycle Bin.
Declaration
public void DeleteMediaOfTypes(IEnumerable<int> mediaTypeIds, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Int32> | mediaTypeIds | Id of the IContentType |
System.Int32 | userId | Optional Id of the user issueing the delete operation |
DeleteVersion(Int32, Guid, Boolean, Int32)
Permanently deletes specific version(s) from an IMedia object. This method will never delete the latest version of a content item.
Declaration
public void DeleteVersion(int id, Guid versionId, bool deletePriorVersions, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IMedia object to delete a version from |
System.Guid | versionId | Id of the version to delete |
System.Boolean | deletePriorVersions | Boolean indicating whether to delete versions prior to the versionId |
System.Int32 | userId | Optional Id of the User deleting versions of a Content object |
DeleteVersions(Int32, DateTime, Int32)
Permanently deletes versions from an IMedia object prior to a specific date. This method will never delete the latest version of a content item.
Declaration
public void DeleteVersions(int id, DateTime versionDate, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IMedia object to delete versions from |
System.DateTime | versionDate | Latest version date |
System.Int32 | userId | Optional Id of the User deleting versions of a Content object |
EmptyRecycleBin()
Empties the Recycle Bin by deleting all IMedia that resides in the bin
Declaration
public void EmptyRecycleBin()
GenerateThumbnails(String, PropertyType)
Declaration
[Obsolete("This should no longer be used, thumbnail generation should be done via ImageProcessor, Umbraco no longer generates '_thumb' files for media")]
public void GenerateThumbnails(string filepath, PropertyType propertyType)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | |
PropertyType | propertyType |
GetAncestors(Int32)
Gets a collection of IMedia objects, which are ancestors of the current media.
Declaration
public IEnumerable<IMedia> GetAncestors(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IMedia to retrieve ancestors for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetAncestors(IMedia)
Gets a collection of IMedia objects, which are ancestors of the current media.
Declaration
public IEnumerable<IMedia> GetAncestors(IMedia media)
Parameters
Type | Name | Description |
---|---|---|
IMedia | media | IMedia to retrieve ancestors for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetById(Guid)
Gets an IMedia object by its 'UniqueId'
Declaration
public IMedia GetById(Guid key)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | key | Guid key of the Media to retrieve |
Returns
Type | Description |
---|---|
IMedia | IMedia |
GetById(Int32)
Gets an IMedia object by Id
Declaration
public IMedia GetById(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Content to retrieve |
Returns
Type | Description |
---|---|
IMedia | IMedia |
GetByIds(IEnumerable<Guid>)
Gets an IMedia objects by Ids
Declaration
public IEnumerable<IMedia> GetByIds(IEnumerable<Guid> ids)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Guid> | ids | Ids of the Media to retrieve |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | IMedia |
GetByIds(IEnumerable<Int32>)
Gets an IMedia objects by Ids
Declaration
public IEnumerable<IMedia> GetByIds(IEnumerable<int> ids)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Int32> | ids | Ids of the Media to retrieve |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | IMedia |
GetByLevel(Int32)
Gets a collection of IMedia objects by Level
Declaration
public IEnumerable<IMedia> GetByLevel(int level)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | level | The level to retrieve Media from |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetByVersion(Guid)
Gets a specific version of an IMedia item.
Declaration
public IMedia GetByVersion(Guid versionId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | versionId | Id of the version to retrieve |
Returns
Type | Description |
---|---|
IMedia | An IMedia item |
GetChildren(Int32)
Gets a collection of IMedia objects by Parent Id
Declaration
public IEnumerable<IMedia> GetChildren(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Children from |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetDescendants(Int32)
Gets descendants of a IMedia object by its Id
Declaration
public IEnumerable<IMedia> GetDescendants(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve descendants from |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable flat list of IMedia objects |
GetDescendants(IMedia)
Gets descendants of a IMedia object by its Id
Declaration
public IEnumerable<IMedia> GetDescendants(IMedia media)
Parameters
Type | Name | Description |
---|---|---|
IMedia | media | The Parent IMedia object to retrieve descendants from |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable flat list of IMedia objects |
GetMediaByPath(String)
Gets an IMedia object from the path stored in the 'umbracoFile' property.
Declaration
public IMedia GetMediaByPath(string mediaPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | mediaPath | Path of the media item to retrieve (for example: /media/1024/koala_403x328.jpg) |
Returns
Type | Description |
---|---|
IMedia | IMedia |
GetMediaFileContentStream(String)
Declaration
public Stream GetMediaFileContentStream(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath |
Returns
Type | Description |
---|---|
System.IO.Stream |
GetMediaFileSize(String)
Declaration
public long GetMediaFileSize(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath |
Returns
Type | Description |
---|---|
System.Int64 |
GetMediaInRecycleBin()
Gets a collection of an IMedia objects, which resides in the Recycle Bin
Declaration
public IEnumerable<IMedia> GetMediaInRecycleBin()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetMediaOfMediaType(Int32)
Gets a collection of IMedia objects by the Id of the IContentType
Declaration
public IEnumerable<IMedia> GetMediaOfMediaType(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IMediaType |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetPagedChildren(Int32, Int32, Int32, out Int32, String, Direction, String)
Declaration
[Obsolete("Use the overload with 'long' parameter types instead")]
public IEnumerable<IMedia> GetPagedChildren(int id, int pageIndex, int pageSize, out int totalChildren, string orderBy, Direction orderDirection, string filter = "")
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | |
System.Int32 | pageIndex | |
System.Int32 | pageSize | |
System.Int32 | totalChildren | |
System.String | orderBy | |
Direction | orderDirection | |
System.String | filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> |
GetPagedChildren(Int32, Int64, Int32, out Int64, String, Direction, Boolean, String)
Gets a collection of IMedia objects by Parent Id
Declaration
public IEnumerable<IMedia> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, bool orderBySystemField, string filter)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Children from |
System.Int64 | pageIndex | Page index (zero based) |
System.Int32 | pageSize | Page size |
System.Int64 | totalChildren | Total records query would return without paging |
System.String | orderBy | Field to order by |
Direction | orderDirection | Direction to order by |
System.Boolean | orderBySystemField | Flag to indicate when ordering by system field |
System.String | filter | Search text filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IContent objects |
GetPagedChildren(Int32, Int64, Int32, out Int64, String, Direction, Boolean, String, Int32[])
Gets a collection of IMedia objects by Parent Id
Declaration
public IEnumerable<IMedia> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, bool orderBySystemField, string filter, int[] contentTypeFilter)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Children from |
System.Int64 | pageIndex | Page number |
System.Int32 | pageSize | Page size |
System.Int64 | totalChildren | Total records query would return without paging |
System.String | orderBy | Field to order by |
Direction | orderDirection | Direction to order by |
System.Boolean | orderBySystemField | Flag to indicate when ordering by system field |
System.String | filter | Search text filter |
System.Int32[] | contentTypeFilter | A list of content type Ids to filter the list by |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IContent objects |
GetPagedChildren(Int32, Int64, Int32, out Int64, String, Direction, String)
Gets a collection of IMedia objects by Parent Id
Declaration
public IEnumerable<IMedia> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, string filter = "")
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Children from |
System.Int64 | pageIndex | Page index (zero based) |
System.Int32 | pageSize | Page size |
System.Int64 | totalChildren | Total records query would return without paging |
System.String | orderBy | Field to order by |
Direction | orderDirection | Direction to order by |
System.String | filter | Search text filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IContent objects |
GetPagedDescendants(Int32, Int32, Int32, out Int32, String, Direction, String)
Declaration
[Obsolete("Use the overload with 'long' parameter types instead")]
public IEnumerable<IMedia> GetPagedDescendants(int id, int pageIndex, int pageSize, out int totalChildren, string orderBy = "path", Direction orderDirection = Direction.Ascending, string filter = "")
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | |
System.Int32 | pageIndex | |
System.Int32 | pageSize | |
System.Int32 | totalChildren | |
System.String | orderBy | |
Direction | orderDirection | |
System.String | filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> |
GetPagedDescendants(Int32, Int64, Int32, out Int64, String, Direction, Boolean, String)
Gets a collection of IContent objects by Parent Id
Declaration
public IEnumerable<IMedia> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, bool orderBySystemField, string filter)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Descendants from |
System.Int64 | pageIndex | Page number |
System.Int32 | pageSize | Page size |
System.Int64 | totalChildren | Total records query would return without paging |
System.String | orderBy | Field to order by |
Direction | orderDirection | Direction to order by |
System.Boolean | orderBySystemField | Flag to indicate when ordering by system field |
System.String | filter | Search text filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IContent objects |
GetPagedDescendants(Int32, Int64, Int32, out Int64, String, Direction, String)
Gets a collection of IContent objects by Parent Id
Declaration
public IEnumerable<IMedia> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy = "path", Direction orderDirection = Direction.Ascending, string filter = "")
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Descendants from |
System.Int64 | pageIndex | Page number |
System.Int32 | pageSize | Page size |
System.Int64 | totalChildren | Total records query would return without paging |
System.String | orderBy | Field to order by |
Direction | orderDirection | Direction to order by |
System.String | filter | Search text filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IContent objects |
GetPagedXmlEntries(String, Int64, Int32, out Int64)
Gets paged media descendants as XML by path
Declaration
public IEnumerable<XElement> GetPagedXmlEntries(string path, long pageIndex, int pageSize, out long totalRecords)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path starts with |
System.Int64 | pageIndex | Page number |
System.Int32 | pageSize | Page size |
System.Int64 | totalRecords | Total records the query would return without paging |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> | A paged enumerable of XML entries of media items |
GetParent(Int32)
Gets the parent of the current media as an IMedia item.
Declaration
public IMedia GetParent(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IMedia to retrieve the parent from |
Returns
Type | Description |
---|---|
IMedia | Parent IMedia object |
GetParent(IMedia)
Gets the parent of the current media as an IMedia item.
Declaration
public IMedia GetParent(IMedia media)
Parameters
Type | Name | Description |
---|---|---|
IMedia | media | IMedia to retrieve the parent from |
Returns
Type | Description |
---|---|
IMedia | Parent IMedia object |
GetRootMedia()
Gets a collection of IMedia objects, which reside at the first level / root
Declaration
public IEnumerable<IMedia> GetRootMedia()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetVersions(Int32)
Gets a collection of an IMedia objects versions by Id
Declaration
public IEnumerable<IMedia> GetVersions(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMedia> | An Enumerable list of IMedia objects |
HasChildren(Int32)
Checks whether an IMedia item has any children
Declaration
public bool HasChildren(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IMedia |
Returns
Type | Description |
---|---|
System.Boolean | True if the media has any children otherwise False |
Move(IMedia, Int32, Int32)
Moves an IMedia object to a new location
Declaration
public void Move(IMedia media, int parentId, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IMedia | media | The IMedia to move |
System.Int32 | parentId | Id of the Media's new Parent |
System.Int32 | userId | Id of the User moving the Media |
MoveToRecycleBin(IMedia, Int32)
Deletes an IMedia object by moving it to the Recycle Bin
Declaration
public void MoveToRecycleBin(IMedia media, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IMedia | media | The IMedia to delete |
System.Int32 | userId | Id of the User deleting the Media |
RebuildXmlStructures(Int32[])
Rebuilds all xml content in the cmsContentXml table for all media
Declaration
public void RebuildXmlStructures(params int[] contentTypeIds)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | contentTypeIds | Only rebuild the xml structures for the content type ids passed in, if none then rebuilds the structures for all media |
Save(IEnumerable<IMedia>, Int32, Boolean)
Saves a collection of IMedia objects
Declaration
public void Save(IEnumerable<IMedia> medias, int userId = 0, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IMedia> | medias | Collection of IMedia to save |
System.Int32 | userId | Id of the User saving the Content |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise events. |
Save(IMedia, Int32, Boolean)
Saves a single IMedia object
Declaration
public void Save(IMedia media, int userId = 0, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
IMedia | media | The IMedia to save |
System.Int32 | userId | Id of the User saving the Content |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise events. |
SetMediaFileContent(String, Stream)
Declaration
public void SetMediaFileContent(string filepath, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | |
System.IO.Stream | stream |
Sort(IEnumerable<IMedia>, Int32, Boolean)
Sorts a collection of IMedia objects by updating the SortOrder according to the ordering of items in the passed in System.Collections.Generic.IEnumerable<T>.
Declaration
public bool Sort(IEnumerable<IMedia> items, int userId = 0, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IMedia> | items | |
System.Int32 | userId | |
System.Boolean | raiseEvents |
Returns
Type | Description |
---|---|
System.Boolean | True if sorting succeeded, otherwise False |
Events
Created
Occurs after Create
Declaration
public static event TypedEventHandler<IMediaService, NewEventArgs<IMedia>> Created
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, NewEventArgs<IMedia>> |
Remarks
Please note that the Media object has been created, but not saved so it does not have an identity yet (meaning no Id has been set).
Creating
Occurs before Create
Declaration
[Obsolete("Use the Created event instead, the Creating and Created events both offer the same functionality, Creating event has been deprecated.")]
public static event TypedEventHandler<IMediaService, NewEventArgs<IMedia>> Creating
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, NewEventArgs<IMedia>> |
Deleted
Occurs after Delete
Declaration
public static event TypedEventHandler<IMediaService, DeleteEventArgs<IMedia>> Deleted
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, DeleteEventArgs<IMedia>> |
DeletedVersions
Occurs after Delete
Declaration
public static event TypedEventHandler<IMediaService, DeleteRevisionsEventArgs> DeletedVersions
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, DeleteRevisionsEventArgs> |
Deleting
Occurs before Delete
Declaration
public static event TypedEventHandler<IMediaService, DeleteEventArgs<IMedia>> Deleting
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, DeleteEventArgs<IMedia>> |
DeletingVersions
Occurs before Delete
Declaration
public static event TypedEventHandler<IMediaService, DeleteRevisionsEventArgs> DeletingVersions
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, DeleteRevisionsEventArgs> |
EmptiedRecycleBin
Occurs after the Recycle Bin has been Emptied
Declaration
public static event TypedEventHandler<IMediaService, RecycleBinEventArgs> EmptiedRecycleBin
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, RecycleBinEventArgs> |
EmptyingRecycleBin
Occurs before the Recycle Bin is emptied
Declaration
public static event TypedEventHandler<IMediaService, RecycleBinEventArgs> EmptyingRecycleBin
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, RecycleBinEventArgs> |
Moved
Occurs after Move
Declaration
public static event TypedEventHandler<IMediaService, MoveEventArgs<IMedia>> Moved
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, MoveEventArgs<IMedia>> |
Moving
Occurs before Move
Declaration
public static event TypedEventHandler<IMediaService, MoveEventArgs<IMedia>> Moving
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, MoveEventArgs<IMedia>> |
Saved
Occurs after Save
Declaration
public static event TypedEventHandler<IMediaService, SaveEventArgs<IMedia>> Saved
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, SaveEventArgs<IMedia>> |
Saving
Occurs before Save
Declaration
public static event TypedEventHandler<IMediaService, SaveEventArgs<IMedia>> Saving
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, SaveEventArgs<IMedia>> |
Trashed
Occurs after Content is moved to Recycle Bin
Declaration
public static event TypedEventHandler<IMediaService, MoveEventArgs<IMedia>> Trashed
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, MoveEventArgs<IMedia>> |
Trashing
Occurs before Content is moved to Recycle Bin
Declaration
public static event TypedEventHandler<IMediaService, MoveEventArgs<IMedia>> Trashing
Event Type
Type | Description |
---|---|
TypedEventHandler<IMediaService, MoveEventArgs<IMedia>> |
Explicit Interface Implementations
IMediaServiceOperations.Delete(IMedia, Int32)
Permanently deletes an IMedia object
Declaration
Attempt<OperationStatus> IMediaServiceOperations.Delete(IMedia media, int userId)
Parameters
Type | Name | Description |
---|---|---|
IMedia | media | The IMedia to delete |
System.Int32 | userId | Id of the User deleting the Media |
Returns
Type | Description |
---|---|
Attempt<OperationStatus> |
Remarks
Please note that this method will completely remove the Media from the database, but current not from the file system.
IMediaServiceOperations.MoveToRecycleBin(IMedia, Int32)
Deletes an IMedia object by moving it to the Recycle Bin
Declaration
Attempt<OperationStatus> IMediaServiceOperations.MoveToRecycleBin(IMedia media, int userId)
Parameters
Type | Name | Description |
---|---|---|
IMedia | media | The IMedia to delete |
System.Int32 | userId | Id of the User deleting the Media |
Returns
Type | Description |
---|---|
Attempt<OperationStatus> |
IMediaServiceOperations.Save(IEnumerable<IMedia>, Int32, Boolean)
Saves a collection of IMedia objects
Declaration
Attempt<OperationStatus> IMediaServiceOperations.Save(IEnumerable<IMedia> medias, int userId, bool raiseEvents)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IMedia> | medias | Collection of IMedia to save |
System.Int32 | userId | Id of the User saving the Media |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise events. |
Returns
Type | Description |
---|---|
Attempt<OperationStatus> |
IMediaServiceOperations.Save(IMedia, Int32, Boolean)
Saves a single IMedia object
Declaration
Attempt<OperationStatus> IMediaServiceOperations.Save(IMedia media, int userId, bool raiseEvents)
Parameters
Type | Name | Description |
---|---|---|
IMedia | media | The IMedia to save |
System.Int32 | userId | Id of the User saving the Media |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise events. |
Returns
Type | Description |
---|---|
Attempt<OperationStatus> |