From 9f2f9f77681f087f81bf9b05d0e8e4e67a9d58cb Mon Sep 17 00:00:00 2001 From: Erik-Jan Westendorp Date: Tue, 22 Oct 2024 16:34:38 +0200 Subject: [PATCH 1/3] Change UmbracoApiController to Controller --- .../getting-started-with-entity-framework-core.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/14/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md b/14/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md index 6b5665bbef2..e1e38158d9b 100644 --- a/14/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md +++ b/14/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md @@ -252,18 +252,19 @@ The example below creates a `UmbracoApiController` to be able to fetch and inser ```csharp using Microsoft.AspNetCore.Mvc; using Umbraco.Cms.Persistence.EFCore.Scoping; -using Umbraco.Cms.Web.Common.Controllers; namespace Umbraco.Demo; -public class BlogCommentsController : UmbracoApiController +[ApiController] +[Route("/umbraco/api/blogcomments")] +public class BlogCommentsController : Controller { private readonly IEFCoreScopeProvider _efCoreScopeProvider; public BlogCommentsController(IEFCoreScopeProvider efCoreScopeProvider) => _efCoreScopeProvider = efCoreScopeProvider; - [HttpGet] + [HttpGet("all")] public async Task All() { using IEfCoreScope scope = _efCoreScopeProvider.CreateScope(); @@ -272,7 +273,7 @@ public class BlogCommentsController : UmbracoApiController return Ok(comments); } - [HttpGet] + [HttpGet("getcomments")] public async Task GetComments(Guid umbracoNodeKey) { using IEfCoreScope scope = _efCoreScopeProvider.CreateScope(); @@ -285,7 +286,7 @@ public class BlogCommentsController : UmbracoApiController return Ok(comments); } - [HttpPost] + [HttpPost("insertcomment")] public async Task InsertComment(BlogComment comment) { using IEfCoreScope scope = _efCoreScopeProvider.CreateScope(); From af3351ec4153b158c8a107971e38a9b3858220f5 Mon Sep 17 00:00:00 2001 From: Erik-Jan Westendorp Date: Tue, 22 Oct 2024 16:35:17 +0200 Subject: [PATCH 2/3] Delete obsolete message --- .../tutorials/getting-started-with-entity-framework-core.md | 1 - 1 file changed, 1 deletion(-) diff --git a/14/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md b/14/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md index e1e38158d9b..003ead1fb76 100644 --- a/14/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md +++ b/14/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md @@ -245,7 +245,6 @@ The example below creates a `UmbracoApiController` to be able to fetch and inser {% hint style="warning" %} * This example uses the `BlogComment` class, which is a database model. The recommended approach would be to map these over to a ViewModel instead, that way your database & UI layers are not coupled. Be aware that things like error handling and data validation have been omitted for brevity. -* The example uses UmbracoApiController which is obsolete in Umbraco 14 and will be removed in Umbraco 15. {% endhint %} From 20325fe6dbf02cf6cbe28389271267f1bc5171b1 Mon Sep 17 00:00:00 2001 From: Erik-Jan Westendorp Date: Tue, 22 Oct 2024 16:41:36 +0200 Subject: [PATCH 3/3] Update v15 --- .../getting-started-with-entity-framework-core.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/15/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md b/15/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md index 6b5665bbef2..003ead1fb76 100644 --- a/15/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md +++ b/15/umbraco-cms/tutorials/getting-started-with-entity-framework-core.md @@ -245,25 +245,25 @@ The example below creates a `UmbracoApiController` to be able to fetch and inser {% hint style="warning" %} * This example uses the `BlogComment` class, which is a database model. The recommended approach would be to map these over to a ViewModel instead, that way your database & UI layers are not coupled. Be aware that things like error handling and data validation have been omitted for brevity. -* The example uses UmbracoApiController which is obsolete in Umbraco 14 and will be removed in Umbraco 15. {% endhint %} ```csharp using Microsoft.AspNetCore.Mvc; using Umbraco.Cms.Persistence.EFCore.Scoping; -using Umbraco.Cms.Web.Common.Controllers; namespace Umbraco.Demo; -public class BlogCommentsController : UmbracoApiController +[ApiController] +[Route("/umbraco/api/blogcomments")] +public class BlogCommentsController : Controller { private readonly IEFCoreScopeProvider _efCoreScopeProvider; public BlogCommentsController(IEFCoreScopeProvider efCoreScopeProvider) => _efCoreScopeProvider = efCoreScopeProvider; - [HttpGet] + [HttpGet("all")] public async Task All() { using IEfCoreScope scope = _efCoreScopeProvider.CreateScope(); @@ -272,7 +272,7 @@ public class BlogCommentsController : UmbracoApiController return Ok(comments); } - [HttpGet] + [HttpGet("getcomments")] public async Task GetComments(Guid umbracoNodeKey) { using IEfCoreScope scope = _efCoreScopeProvider.CreateScope(); @@ -285,7 +285,7 @@ public class BlogCommentsController : UmbracoApiController return Ok(comments); } - [HttpPost] + [HttpPost("insertcomment")] public async Task InsertComment(BlogComment comment) { using IEfCoreScope scope = _efCoreScopeProvider.CreateScope();