Table of Contents

Class DataTypeController

Namespace
Umbraco.Cms.Web.BackOffice.Controllers
Assembly
Umbraco.Web.BackOffice.dll

The API controller used for editing data types

[Authorize(Policy = "TreeAccessDocumentsOrDocumentTypes")]
public class DataTypeController : BackOfficeNotificationsController
Inheritance
DataTypeController
Inherited Members

Remarks

The security for this controller is defined to allow full CRUD access to data types if the user has access to either: Content Types, Member Types or Media Types ... and of course to Data Types

Constructors

DataTypeController(PropertyEditorCollection, IDataTypeService, IOptionsSnapshot<ContentSettings>, IUmbracoMapper, PropertyEditorCollection, IContentTypeService, IMediaTypeService, IMemberTypeService, ILocalizedTextService, IBackOfficeSecurityAccessor, IConfigurationEditorJsonSerializer)

[Obsolete("Use constructor that takes IDataTypeUsageService, scheduled for removal in V12")]
public DataTypeController(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IOptionsSnapshot<ContentSettings> contentSettings, IUmbracoMapper umbracoMapper, PropertyEditorCollection propertyEditorCollection, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, ILocalizedTextService localizedTextService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IConfigurationEditorJsonSerializer serializer)

Parameters

propertyEditors PropertyEditorCollection
dataTypeService IDataTypeService
contentSettings IOptionsSnapshot<ContentSettings>
umbracoMapper IUmbracoMapper
propertyEditorCollection PropertyEditorCollection
contentTypeService IContentTypeService
mediaTypeService IMediaTypeService
memberTypeService IMemberTypeService
localizedTextService ILocalizedTextService
backOfficeSecurityAccessor IBackOfficeSecurityAccessor
serializer IConfigurationEditorJsonSerializer

DataTypeController(PropertyEditorCollection, IDataTypeService, IOptionsSnapshot<ContentSettings>, IUmbracoMapper, PropertyEditorCollection, IContentTypeService, IMediaTypeService, IMemberTypeService, ILocalizedTextService, IBackOfficeSecurityAccessor, IConfigurationEditorJsonSerializer, IDataTypeUsageService)

[ActivatorUtilitiesConstructor]
public DataTypeController(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IOptionsSnapshot<ContentSettings> contentSettings, IUmbracoMapper umbracoMapper, PropertyEditorCollection propertyEditorCollection, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, ILocalizedTextService localizedTextService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IConfigurationEditorJsonSerializer serializer, IDataTypeUsageService dataTypeUsageService)

Parameters

propertyEditors PropertyEditorCollection
dataTypeService IDataTypeService
contentSettings IOptionsSnapshot<ContentSettings>
umbracoMapper IUmbracoMapper
propertyEditorCollection PropertyEditorCollection
contentTypeService IContentTypeService
mediaTypeService IMediaTypeService
memberTypeService IMemberTypeService
localizedTextService ILocalizedTextService
backOfficeSecurityAccessor IBackOfficeSecurityAccessor
serializer IConfigurationEditorJsonSerializer
dataTypeUsageService IDataTypeUsageService

Methods

DeleteById(int)

Deletes a data type with a given ID

[HttpDelete]
[HttpPost]
public IActionResult DeleteById(int id)

Parameters

id int

Returns

IActionResult

DeleteContainer(int)

Deletes a data type container with a given ID

[HttpDelete]
[HttpPost]
public IActionResult DeleteContainer(int id)

Parameters

id int

Returns

IActionResult

GetAll()

Gets the content json for all data types

[Authorize(Policy = "SectionAccessForDataTypeReading")]
public IEnumerable<DataTypeBasic>? GetAll()

Returns

IEnumerable<DataTypeBasic>

Remarks

Permission is granted to this method if the user has access to any of these sections: Content, media, settings, developer, members

GetAllPropertyEditors()

Gets all property editors defined

[Authorize(Policy = "SectionAccessForDataTypeReading")]
public IEnumerable<PropertyEditorBasic> GetAllPropertyEditors()

Returns

IEnumerable<PropertyEditorBasic>

Remarks

Permission is granted to this method if the user has access to any of these sections: Content, media, settings, developer, members

GetById(Guid)

Gets the datatype json for the datatype guid

public ActionResult<DataTypeDisplay?> GetById(Guid id)

Parameters

id Guid

Returns

ActionResult<DataTypeDisplay>

GetById(int)

Gets the datatype json for the datatype id

public ActionResult<DataTypeDisplay?> GetById(int id)

Parameters

id int

Returns

ActionResult<DataTypeDisplay>

GetById(Udi)

Gets the datatype json for the datatype udi

public ActionResult<DataTypeDisplay?> GetById(Udi id)

Parameters

id Udi

Returns

ActionResult<DataTypeDisplay>

GetByName(string)

Gets data type by name

public DataTypeDisplay? GetByName(string name)

Parameters

name string

Returns

DataTypeDisplay

GetCustomListView(string)

Returns a custom listview, based on a content type alias, if found

public ActionResult<DataTypeDisplay?> GetCustomListView(string contentTypeAlias)

Parameters

contentTypeAlias string

Returns

ActionResult<DataTypeDisplay>

a DataTypeDisplay

GetEmpty(int)

public DataTypeDisplay? GetEmpty(int parentId)

Parameters

parentId int

Returns

DataTypeDisplay

GetGroupedDataTypes()

Returns all data types grouped by their property editor group

[Authorize(Policy = "SectionAccessForDataTypeReading")]
public IDictionary<string, IEnumerable<DataTypeBasic>>? GetGroupedDataTypes()

Returns

IDictionary<string, IEnumerable<DataTypeBasic>>

Remarks

Permission is granted to this method if the user has access to any of these sections: Content, media, settings, developer, members

GetGroupedPropertyEditors()

Returns all property editors grouped

[Authorize(Policy = "SectionAccessForDataTypeReading")]
public IDictionary<string, IEnumerable<DataTypeBasic>> GetGroupedPropertyEditors()

Returns

IDictionary<string, IEnumerable<DataTypeBasic>>

Remarks

Permission is granted to this method if the user has access to any of these sections: Content, media, settings, developer, members

GetPreValues(string, int)

Returns the pre-values for the specified property editor

public ActionResult<IEnumerable<DataTypeConfigurationFieldDisplay>> GetPreValues(string editorAlias, int dataTypeId = -1)

Parameters

editorAlias string
dataTypeId int

The data type id for the pre-values, -1 if it is a new data type

Returns

ActionResult<IEnumerable<DataTypeConfigurationFieldDisplay>>

GetReferences(int)

Returns the references (usages) for the data type

public DataTypeReferences GetReferences(int id)

Parameters

id int

Returns

DataTypeReferences

HasValues(int)

[HttpGet]
public ActionResult<DataTypeHasValuesDisplay> HasValues(int id)

Parameters

id int

Returns

ActionResult<DataTypeHasValuesDisplay>

PostCopy(MoveOrCopy)

public IActionResult PostCopy(MoveOrCopy copy)

Parameters

copy MoveOrCopy

Returns

IActionResult

PostCreateContainer(int, string)

public IActionResult PostCreateContainer(int parentId, string name)

Parameters

parentId int
name string

Returns

IActionResult

PostCreateCustomListView(string)

Creates a custom list view - give a document type alias

public DataTypeDisplay? PostCreateCustomListView(string contentTypeAlias)

Parameters

contentTypeAlias string

Returns

DataTypeDisplay

PostMove(MoveOrCopy)

Move the media type

public IActionResult PostMove(MoveOrCopy move)

Parameters

move MoveOrCopy

Returns

IActionResult

PostRenameContainer(int, string)

public IActionResult PostRenameContainer(int id, string name)

Parameters

id int
name string

Returns

IActionResult

PostSave(DataTypeSave)

Saves the data type

public ActionResult<DataTypeDisplay?> PostSave(DataTypeSave dataType)

Parameters

dataType DataTypeSave

Returns

ActionResult<DataTypeDisplay>