Skip to content
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

Allow invariant type/part definition lookup in ContentDefinitionManager #12102

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public async Task<ActionResult> AddPartsTo(string id)
{
Type = typeViewModel,
PartSelections = _contentDefinitionService.GetParts(metadataPartsOnly: false)
.Where(cpd => !typePartNames.Contains(cpd.Name) && cpd.PartDefinition != null ? cpd.PartDefinition.GetSettings<ContentPartSettings>().Attachable : false)
.Where(cpd => !typePartNames.Contains(cpd.Name, StringComparer.OrdinalIgnoreCase) && cpd.PartDefinition != null ? cpd.PartDefinition.GetSettings<ContentPartSettings>().Attachable : false)
.Select(cpd => new PartSelectionViewModel { PartName = cpd.Name, PartDisplayName = cpd.DisplayName, PartDescription = cpd.Description })
.ToList()
};
Expand Down Expand Up @@ -409,7 +409,7 @@ public async Task<ActionResult> RemovePart(string id, string name)

var typeViewModel = _contentDefinitionService.LoadType(id);

if (typeViewModel == null || !typeViewModel.TypeDefinition.Parts.Any(p => p.Name == name))
if (typeViewModel == null || !typeViewModel.TypeDefinition.Parts.Any(p => String.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase)))
{
return NotFound();
}
Expand Down Expand Up @@ -691,7 +691,7 @@ public async Task<ActionResult> EditField(string id, string name, string returnU
return NotFound();
}

var partFieldDefinition = partViewModel.PartDefinition.Fields.FirstOrDefault(x => x.Name == name);
var partFieldDefinition = partViewModel.PartDefinition.Fields.FirstOrDefault(x => String.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));

if (partFieldDefinition == null)
{
Expand Down Expand Up @@ -733,7 +733,7 @@ public async Task<ActionResult> EditFieldPOST(string id, EditFieldViewModel view
return NotFound();
}

var field = _contentDefinitionManager.LoadPartDefinition(id).Fields.FirstOrDefault(x => x.Name == viewModel.Name);
var field = _contentDefinitionManager.LoadPartDefinition(id).Fields.FirstOrDefault(x => String.Equals(x.Name, viewModel.Name, StringComparison.OrdinalIgnoreCase));

if (field == null)
{
Expand Down Expand Up @@ -773,7 +773,7 @@ public async Task<ActionResult> EditFieldPOST(string id, EditFieldViewModel view
_contentDefinitionService.AlterField(partViewModel, viewModel);

// Refresh the local field variable in case it has been altered
field = _contentDefinitionManager.LoadPartDefinition(id).Fields.FirstOrDefault(x => x.Name == viewModel.Name);
field = _contentDefinitionManager.LoadPartDefinition(id).Fields.FirstOrDefault(x => String.Equals(x.Name, viewModel.Name, StringComparison.OrdinalIgnoreCase));

viewModel.Shape = await _contentDefinitionDisplayManager.UpdatePartFieldEditorAsync(field, _updateModelAccessor.ModelUpdater);

Expand Down Expand Up @@ -821,7 +821,7 @@ public async Task<ActionResult> RemoveFieldFromPOST(string id, string name)
return NotFound();
}

var field = partViewModel.PartDefinition.Fields.FirstOrDefault(x => x.Name == name);
var field = partViewModel.PartDefinition.Fields.FirstOrDefault(x => String.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));

if (field == null)
{
Expand Down Expand Up @@ -858,7 +858,7 @@ public async Task<ActionResult> EditTypePart(string id, string name)
return NotFound();
}

var typePartDefinition = typeDefinition.Parts.FirstOrDefault(x => x.Name == name);
var typePartDefinition = typeDefinition.Parts.FirstOrDefault(x => String.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));

if (typePartDefinition == null)
{
Expand Down Expand Up @@ -900,7 +900,7 @@ public async Task<ActionResult> EditTypePartPOST(string id, EditTypePartViewMode
return NotFound();
}

var part = typeDefinition.Parts.FirstOrDefault(x => x.Name == viewModel.Name);
var part = typeDefinition.Parts.FirstOrDefault(x => String.Equals(x.Name, viewModel.Name, StringComparison.OrdinalIgnoreCase));

if (part == null)
{
Expand Down Expand Up @@ -938,7 +938,7 @@ public async Task<ActionResult> EditTypePartPOST(string id, EditTypePartViewMode
_contentDefinitionService.AlterTypePart(viewModel);

// Refresh the local part variable in case it has been altered
part = _contentDefinitionManager.LoadTypeDefinition(id).Parts.FirstOrDefault(x => x.Name == viewModel.Name);
part = _contentDefinitionManager.LoadTypeDefinition(id).Parts.FirstOrDefault(x => String.Equals(x.Name, viewModel.Name, StringComparison.OrdinalIgnoreCase));

viewModel.Shape = await _contentDefinitionDisplayManager.UpdateTypePartEditorAsync(part, _updateModelAccessor.ModelUpdater);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ContentPartDefinitionBuilder Named(string name)

public ContentPartDefinitionBuilder RemoveField(string fieldName)
{
var existingField = _fields.SingleOrDefault(x => x.Name == fieldName);
var existingField = _fields.SingleOrDefault(x => String.Equals(x.Name, fieldName, StringComparison.OrdinalIgnoreCase));
if (existingField != null)
{
_fields.Remove(existingField);
Expand Down Expand Up @@ -123,7 +123,7 @@ public ContentPartDefinitionBuilder WithField(string fieldName)

public ContentPartDefinitionBuilder WithField(string fieldName, Action<ContentPartFieldDefinitionBuilder> configuration)
{
var existingField = _fields.FirstOrDefault(x => x.Name == fieldName);
var existingField = _fields.FirstOrDefault(x => String.Equals(x.Name, fieldName, StringComparison.OrdinalIgnoreCase));
if (existingField != null)
{
var toRemove = _fields.Where(x => x.Name == fieldName).ToArray();
Expand All @@ -144,7 +144,7 @@ public ContentPartDefinitionBuilder WithField(string fieldName, Action<ContentPa

public async Task<ContentPartDefinitionBuilder> WithFieldAsync(string fieldName, Func<ContentPartFieldDefinitionBuilder, Task> configurationAsync)
{
var existingField = _fields.FirstOrDefault(x => x.Name == fieldName);
var existingField = _fields.FirstOrDefault(x => String.Equals(x.Name, fieldName, StringComparison.OrdinalIgnoreCase));

if (existingField != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public ContentTypeDefinitionBuilder WithSettings<T>(T settings)

public ContentTypeDefinitionBuilder RemovePart(string partName)
{
var existingPart = _parts.SingleOrDefault(x => x.Name == partName);
var existingPart = _parts.SingleOrDefault(x => String.Equals(x.Name, partName, StringComparison.OrdinalIgnoreCase));
if (existingPart != null)
{
_parts.Remove(existingPart);
Expand Down Expand Up @@ -144,7 +144,7 @@ public ContentTypeDefinitionBuilder WithPart(string partName, Action<ContentType

public ContentTypeDefinitionBuilder WithPart(string name, ContentPartDefinition partDefinition, Action<ContentTypePartDefinitionBuilder> configuration)
{
var existingPart = _parts.FirstOrDefault(x => x.Name == name);
var existingPart = _parts.FirstOrDefault(x => String.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));
if (existingPart != null)
{
_parts.Remove(existingPart);
Expand Down Expand Up @@ -173,7 +173,7 @@ public Task<ContentTypeDefinitionBuilder> WithPartAsync(string partName, Func<Co

public async Task<ContentTypeDefinitionBuilder> WithPartAsync(string name, ContentPartDefinition partDefinition, Func<ContentTypePartDefinitionBuilder, Task> configurationAsync)
{
var existingPart = _parts.FirstOrDefault(x => x.Name == name);
var existingPart = _parts.FirstOrDefault(x => String.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));

if (existingPart != null)
{
Expand Down
Loading