-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Management API: Return not found from request for content references when entity does not exist (closes #20997) #20999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
08ec4bc
174650c
b48bcc1
211a663
8e0c060
9cdf7e6
34b2d6f
26525fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,13 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Umbraco.Cms.Api.Common.ViewModels.Pagination; | ||
| using Umbraco.Cms.Api.Management.Factories; | ||
| using Umbraco.Cms.Api.Management.ViewModels.TrackedReferences; | ||
| using Umbraco.Cms.Core.DependencyInjection; | ||
| using Umbraco.Cms.Core.Models; | ||
| using Umbraco.Cms.Core.Models.Entities; | ||
| using Umbraco.Cms.Core.Services; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.Document.References; | ||
|
|
@@ -14,11 +17,28 @@ public class ReferencedByDocumentController : DocumentControllerBase | |
| { | ||
| private readonly ITrackedReferencesService _trackedReferencesService; | ||
| private readonly IRelationTypePresentationFactory _relationTypePresentationFactory; | ||
| private readonly IEntityService _entityService; | ||
|
|
||
| public ReferencedByDocumentController(ITrackedReferencesService trackedReferencesService, IRelationTypePresentationFactory relationTypePresentationFactory) | ||
| [Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 19.")] | ||
| public ReferencedByDocumentController( | ||
| ITrackedReferencesService trackedReferencesService, | ||
| IRelationTypePresentationFactory relationTypePresentationFactory) | ||
| : this( | ||
| trackedReferencesService, | ||
| relationTypePresentationFactory, | ||
| StaticServiceProvider.Instance.GetRequiredService<IEntityService>()) | ||
| { | ||
| } | ||
|
|
||
| [ActivatorUtilitiesConstructor] | ||
| public ReferencedByDocumentController( | ||
| ITrackedReferencesService trackedReferencesService, | ||
| IRelationTypePresentationFactory relationTypePresentationFactory, | ||
| IEntityService entityService) | ||
| { | ||
| _trackedReferencesService = trackedReferencesService; | ||
| _relationTypePresentationFactory = relationTypePresentationFactory; | ||
| _entityService = entityService; | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -31,12 +51,19 @@ public ReferencedByDocumentController(ITrackedReferencesService trackedReference | |
| [HttpGet("{id:guid}/referenced-by")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(typeof(PagedViewModel<IReferenceResponseModel>), StatusCodes.Status200OK)] | ||
| [ProducesResponseType(StatusCodes.Status404NotFound)] | ||
| public async Task<ActionResult<PagedViewModel<IReferenceResponseModel>>> ReferencedBy( | ||
| CancellationToken cancellationToken, | ||
| Guid id, | ||
| int skip = 0, | ||
| int take = 20) | ||
| { | ||
| IEntitySlim? entity = _entityService.Get(id, UmbracoObjectTypes.Document); | ||
| if (entity is null) | ||
| { | ||
| return NotFound(); | ||
| } | ||
|
||
|
|
||
| PagedModel<RelationItemModel> relationItems = await _trackedReferencesService.GetPagedRelationsForItemAsync(id, skip, take, true); | ||
|
|
||
| var pagedViewModel = new PagedViewModel<IReferenceResponseModel> | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.