Added null checks (#8511)

The added null checks manage properly importing definitions that do not contain the properties.
This commit is contained in:
Matteo Piovanelli
2021-09-24 08:37:25 +02:00
committed by GitHub
parent d51418b2c1
commit e771a56c42

View File

@@ -137,16 +137,21 @@ namespace Orchard.Projections.Settings {
var settings = part.Settings.GetModel<ProjectionPartSettings>();
// from identity part of the query and guid of the layout find reference
settings.QueryLayoutRecordId = GetQueryLayoutRecord(settings.IdentityQueryLayoutRecord);
settings.QueryLayoutRecordId = string.IsNullOrWhiteSpace(settings.IdentityQueryLayoutRecord)
? "-1" : GetQueryLayoutRecord(settings.IdentityQueryLayoutRecord);
List<string> identityForFilterQuery = new List<string>();
foreach (var record in settings.IdentityFilterQueryRecord.Split('&').ToList()) {
var correctId = GetQueryLayoutRecord(record);
if (!string.IsNullOrEmpty(correctId)) {
identityForFilterQuery.Add(correctId);
if (!string.IsNullOrWhiteSpace(settings.IdentityFilterQueryRecord)) {
List<string> identityForFilterQuery = new List<string>();
foreach (var record in settings.IdentityFilterQueryRecord.Split('&').ToList()) {
var correctId = GetQueryLayoutRecord(record);
if (!string.IsNullOrEmpty(correctId)) {
identityForFilterQuery.Add(correctId);
}
}
settings.FilterQueryRecordId = string.Join("&", identityForFilterQuery);
} else {
settings.FilterQueryRecordId = string.Empty;
}
settings.FilterQueryRecordId = string.Join("&", identityForFilterQuery);
_contentDefinitionManager.AlterTypeDefinition(context.ContentTypeDefinition.Name, cfg => cfg
.WithPart(part.PartDefinition.Name,
@@ -261,4 +266,4 @@ namespace Orchard.Projections.Settings {
return String.IsNullOrWhiteSpace(l.Description) ? descriptor.Display(new LayoutContext { State = FormParametersHelper.ToDynamic(l.State) }).Text : l.Description;
}
}
}
}