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,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@@ -12,69 +9,69 @@ using Umbraco.Cms.Core.Trees;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Authorization;
using Umbraco.Cms.Web.Common.DependencyInjection;
using Constants = Umbraco.Cms.Core.Constants;
namespace Umbraco.Cms.Web.BackOffice.Trees
namespace Umbraco.Cms.Web.BackOffice.Trees;
[Authorize(Policy = AuthorizationPolicies.TreeAccessMemberGroups)]
[Tree(Constants.Applications.Members, Constants.Trees.MemberGroups, SortOrder = 1)]
[PluginController(Constants.Web.Mvc.BackOfficeTreeArea)]
[CoreTree]
public class MemberGroupTreeController : MemberTypeAndGroupTreeControllerBase
{
[Authorize(Policy = AuthorizationPolicies.TreeAccessMemberGroups)]
[Tree(Constants.Applications.Members, Constants.Trees.MemberGroups, SortOrder = 1)]
[PluginController(Constants.Web.Mvc.BackOfficeTreeArea)]
[CoreTree]
public class MemberGroupTreeController : MemberTypeAndGroupTreeControllerBase
private readonly IMemberGroupService _memberGroupService;
[
ActivatorUtilitiesConstructor]
public MemberGroupTreeController(
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IMemberGroupService memberGroupService,
IEventAggregator eventAggregator,
IMemberTypeService memberTypeService)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator,
memberTypeService)
=> _memberGroupService = memberGroupService;
[Obsolete("Use ctor with all params")]
public MemberGroupTreeController(
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IMemberGroupService memberGroupService,
IEventAggregator eventAggregator)
: this(localizedTextService,
umbracoApiControllerTypeCollection,
menuItemCollectionFactory,
memberGroupService,
eventAggregator,
StaticServiceProvider.Instance.GetRequiredService<IMemberTypeService>())
{
private readonly IMemberGroupService _memberGroupService;
}
[
ActivatorUtilitiesConstructor]
public MemberGroupTreeController(
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IMemberGroupService memberGroupService,
IEventAggregator eventAggregator,
IMemberTypeService memberTypeService)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator, memberTypeService)
=> _memberGroupService = memberGroupService;
[Obsolete("Use ctor with all params")]
public MemberGroupTreeController(
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IMemberGroupService memberGroupService,
IEventAggregator eventAggregator)
: this(localizedTextService,
umbracoApiControllerTypeCollection,
menuItemCollectionFactory,
memberGroupService,
eventAggregator,
StaticServiceProvider.Instance.GetRequiredService<IMemberTypeService>())
protected override IEnumerable<TreeNode> GetTreeNodesFromService(string id, FormCollection queryStrings)
=> _memberGroupService.GetAll()
.OrderBy(x => x.Name)
.Select(dt =>
CreateTreeNode(dt.Id.ToString(), id, queryStrings, dt.Name, Constants.Icons.MemberGroup, false));
protected override ActionResult<TreeNode?> CreateRootNode(FormCollection queryStrings)
{
ActionResult<TreeNode?> rootResult = base.CreateRootNode(queryStrings);
if (!(rootResult.Result is null))
{
return rootResult.Result;
}
TreeNode? root = rootResult.Value;
protected override IEnumerable<TreeNode> GetTreeNodesFromService(string id, FormCollection queryStrings)
=> _memberGroupService.GetAll()
.OrderBy(x => x.Name)
.Select(dt => CreateTreeNode(dt.Id.ToString(), id, queryStrings, dt.Name, Constants.Icons.MemberGroup, false));
protected override ActionResult<TreeNode?> CreateRootNode(FormCollection queryStrings)
if (root is not null)
{
ActionResult<TreeNode?> rootResult = base.CreateRootNode(queryStrings);
if (!(rootResult.Result is null))
{
return rootResult.Result;
}
TreeNode? root = rootResult.Value;
if (root is not null)
{
// Check if there are any groups
root.HasChildren = _memberGroupService.GetAll().Any();
}
return root;
// Check if there are any groups
root.HasChildren = _memberGroupService.GetAll().Any();
}
return root;
}
}