Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
e2b9c91
update services articles in v14
alina-tincas Mar 26, 2024
b5ae9c2
moving examples to the root
alina-tincas Mar 27, 2024
db078a5
Update 14/umbraco-cms/reference/management/services/retrieving-conten…
alina-tincas Mar 27, 2024
5d25cfb
Update 14/umbraco-cms/reference/management/services/README.md
alina-tincas Mar 27, 2024
8065132
Update 14/umbraco-cms/reference/management/services/README.md
alina-tincas Mar 27, 2024
a3bc450
Update 14/umbraco-cms/reference/management/services/README.md
alina-tincas Mar 27, 2024
b097142
Update 14/umbraco-cms/reference/management/services/create-a-new-user.md
alina-tincas Mar 27, 2024
b3f5f59
Update 14/umbraco-cms/reference/management/services/create-a-new-user.md
alina-tincas Mar 27, 2024
90b04ec
Update 14/umbraco-cms/reference/management/services/relationservice.md
alina-tincas Mar 27, 2024
657c83b
Update 14/umbraco-cms/reference/management/services/retrieving-conten…
alina-tincas Mar 27, 2024
1c97131
Update 14/umbraco-cms/reference/management/services/retrieving-langua…
alina-tincas Mar 27, 2024
1df4e57
Update 14/umbraco-cms/reference/management/services/README.md
alina-tincas Mar 27, 2024
15fca8b
Update 14/umbraco-cms/reference/management/services/README.md
alina-tincas Mar 27, 2024
88bd162
alphabetize list of services
alina-tincas Mar 27, 2024
53d459f
Update 14/umbraco-cms/reference/management/services/create-a-new-user.md
alina-tincas Mar 27, 2024
cb05e1a
Update 14/umbraco-cms/reference/management/services/retrieving-conten…
alina-tincas Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 104 additions & 1 deletion 14/umbraco-cms/reference/management/services/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,104 @@
# Services Reference
---
description: List of service references along with instructions on how to use them, as well as some examples for better understanding.
---

# Service References

Below you can find a list of most common services:

## [AuditService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IAuditService.html)

## [ConsentService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IConsentService.html)

## [ContentService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IContentService.html)

## [ContentTypeService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IContentTypeService.html)

## [DataTypeService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IDataTypeService.html)

## [DomainService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IDomainService.html)

## [EntityService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IEntityService.html)

## [ExternalLoginService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.ExternalLoginService.html)

## [FileService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IFileService.html)

## [LocalizationService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.ILocalizationService.html)

## [LocalizedTextService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.LocalizedTextService.html)

## [MediaService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IMediaService.html)

## [MemberGroupService](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Services.IMemberGroupService.html)

## [MemberService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IMemberService.html)

## [MemberTypeService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IMemberTypeService.html)

## [NotificationService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.INotificationService.html)

## [PackagingService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IPackagingService.html)

## [PublicAccessService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IPublicAccessService.html)

## [RedirectUrlService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IRedirectUrlService.html)

## [RelationService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IRelationService.html)

## [ServerRegistrationService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IServerRegistrationService.html)

## [TagService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.ITagService.html)

## [UserService](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.IUserService.html)

You can find a list of all supported services in the [API Docs](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.html).

# Getting a Service

All services can be accessed with the following using statement:

```csharp
using Umbraco.Cms.Core.Services;
```

In some cases, you can use [Dependency Injection](https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection). For example, if you have registered your class in Umbraco's dependency injection, you can specify the service interface in your constructor.

For example, if you use a `NotificationService` you can use Dependency Injection via the `INotificationService` interface like this:

```csharp
public class MyClass
{
private INotificationService _notificationService;

public MyClass(INotificationService notificationService)
{
_notificationService = notificationService;
}
}
```

In Razor views, you can access the Notification Service through the `@inject` directive:

```csharp
@inject INotificationService NotificationService
```

You can use the above example for other services where you can replace the interface and service name.

# Samples

* [Consent Service Example](./consentservice.md)
Example of how to work with a Consent.
* [User Service Example](./create-a-new-user.md)
Example of adding a user to a user group.
* [Content Service Example](./create-content-programmatically.md)
Example of creating content programmatically.
* [Media Service Example](./mediaservice.md)
Examples of how to create a new folder and a new media item from a stream.
* [Relation Service Example](./relationservice.md)
Example of how to automatically relate to root node.
* [Content Type Service Example](./retrieving-content-types.md)
Examples of how to retrieve content types and content type containers.
* [Localization Service Example](./retrieving-languages.md)
Example on how to retrieve languages.
48 changes: 0 additions & 48 deletions 14/umbraco-cms/reference/management/services/auditservice.md

This file was deleted.

13 changes: 1 addition & 12 deletions 14/umbraco-cms/reference/management/services/consentservice.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# ConsentService

[Browse the API documentation for ConsentService](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Services.IConsentService.html).

* **Namespace:** `Umbraco.Cms.Core.Services`
* **Assembly:** `Umbraco.Core.dll`

A service for handling lawful data processing requirements.

## What is a Consent
Expand All @@ -17,7 +12,7 @@ Consent can be given or revoked or changed via the `RegisterConsent` method, whi

## Get the current state

Getter methods of this service return the current state of a consent, that is the latest [IConsent](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Models.IConsent.html) entity that was created.
Getter methods of this service return the current state of a consent, that is the latest [IConsent](https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Models.IConsent.html) entity that was created.

## Revoking a consent

Expand Down Expand Up @@ -46,9 +41,3 @@ if (consents != null && consents.Any())
}
}
```

In Razor views, you can access the consent service through the `@inject` directive:

```csharp
@inject IConsentService ConsentService
```

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
---
description: "This will show you how to create a new user using the UserService in Umbraco."
description: This will show you how to add a user to a user group using the UserService in Umbraco.
---

# Getting the service

## Services property

If you wish to use the UserService in a class that inherits from one of the Umbraco base classes. For example: `SurfaceController`, `UmbracoApiController`, or `UmbracoAuthorizedApiController`). You can access the service through a local `Services` property:

```csharp
IUserService userService = Services.UserService;
```

## Static accessor

If neither a `Services` property nor Dependency Injection is available, you can reference the static `Current` class directly:

```csharp
IUserService userService = Umbraco.Core.Composing.Current.Services.UserService;
```

# Creating a user

If you want to create a new user, you'd use ASP.NET identity APIs like it is used in core.

### Assigning the user to a user group
## Assigning the user to a user group

Permissions aren't administered for the specific user, but rather for the user group(s) that the user is a part of. So to add our new user to a user group, we first need to get a reference to the user via the `GetUserGroupByAlias` method, and then use the `AddGroup` method for adding the group to our user:

```csharp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: Example on how to create content programmatically using the ContentService.
---

# Create content programmatically

In the example below, a new page is programmatically created using the content service. It is assumed that there are two document types, namely Catalogue and Product. In this case, a new Product is added underneath the Catalogue page. Add the below code in the Catalogue template.
Expand All @@ -23,8 +27,9 @@ In the example below, a new page is programmatically created using the content s

// Save and publish the child item
ContentService.SaveAndPublish(demoproduct);
```

}
```

In a multilanguage setup, it is necessary to set the name of the content item for a specified culture:

Expand All @@ -33,4 +38,4 @@ demoproduct.SetCultureName("Microphone", "en-us"); // this will set the english
demoproduct.SetCultureName("Mikrofon", "da"); // this will set the danish name
```

For information on how to retrieve multilingual languages, see the [Retrieving languages](../localizationservice/retrieving-languages.md) article.
For information on how to retrieve multilingual languages, see the [Retrieving languages](./retrieving-languages.md) article.
Loading