V10: fix build warnings in Web.BackOffice (#12479)

* Run code cleanup

* Start manual run

* Finish dotnet format + manual cleanup

* Fix up after merge

* Fix substrings changed to [..]

Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk>
Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
Nikolaj Geisle
2022-06-20 08:37:17 +02:00
committed by GitHub
parent 7688c61621
commit e762fa91bc
234 changed files with 28037 additions and 27527 deletions

View File

@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
@@ -9,48 +7,42 @@ using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Authorization;
using Umbraco.Extensions;
using Constants = Umbraco.Cms.Core.Constants;
namespace Umbraco.Cms.Web.BackOffice.Controllers
namespace Umbraco.Cms.Web.BackOffice.Controllers;
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
[Authorize(Policy = AuthorizationPolicies.SectionAccessContent)]
public class RelationController : UmbracoAuthorizedJsonController
{
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
[Authorize(Policy = AuthorizationPolicies.SectionAccessContent)]
public class RelationController : UmbracoAuthorizedJsonController
private readonly IRelationService _relationService;
private readonly IUmbracoMapper _umbracoMapper;
public RelationController(IUmbracoMapper umbracoMapper, IRelationService relationService)
{
private readonly IUmbracoMapper _umbracoMapper;
private readonly IRelationService _relationService;
_umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper));
_relationService = relationService ?? throw new ArgumentNullException(nameof(relationService));
}
public RelationController(IUmbracoMapper umbracoMapper,
IRelationService relationService)
public RelationDisplay? GetById(int id) =>
_umbracoMapper.Map<IRelation, RelationDisplay>(_relationService.GetById(id));
//[EnsureUserPermissionForContent("childId")]
public IEnumerable<RelationDisplay> GetByChildId(int childId, string relationTypeAlias = "")
{
IRelation[] relations = _relationService.GetByChildId(childId).ToArray();
if (relations.Any() == false)
{
_umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper));
_relationService = relationService ?? throw new ArgumentNullException(nameof(relationService));
return Enumerable.Empty<RelationDisplay>();
}
public RelationDisplay? GetById(int id)
if (string.IsNullOrWhiteSpace(relationTypeAlias) == false)
{
return _umbracoMapper.Map<IRelation, RelationDisplay>(_relationService.GetById(id));
}
//[EnsureUserPermissionForContent("childId")]
public IEnumerable<RelationDisplay> GetByChildId(int childId, string relationTypeAlias = "")
{
var relations = _relationService.GetByChildId(childId).ToArray();
if (relations.Any() == false)
{
return Enumerable.Empty<RelationDisplay>();
}
if (string.IsNullOrWhiteSpace(relationTypeAlias) == false)
{
return
_umbracoMapper.MapEnumerable<IRelation, RelationDisplay>(
relations.Where(x => x.RelationType.Alias.InvariantEquals(relationTypeAlias))).WhereNotNull();
}
return _umbracoMapper.MapEnumerable<IRelation, RelationDisplay>(relations).WhereNotNull();
return
_umbracoMapper.MapEnumerable<IRelation, RelationDisplay>(
relations.Where(x => x.RelationType.Alias.InvariantEquals(relationTypeAlias))).WhereNotNull();
}
return _umbracoMapper.MapEnumerable<IRelation, RelationDisplay>(relations).WhereNotNull();
}
}