protected override DriverResult Editor(FeedSyncProfilePart part, IUpdateModel updater, dynamic shapeHelper) { var oldContentTypeValue = part.ContentType; var oldFeedUrl = part.FeedUrl; if (updater.TryUpdateModel(part, Prefix, null, null)) { // These properties cannot be changed, because the mappings will be generated according // to this type and URL. if (part.PublishedCount >= 1) { part.ContentType = oldContentTypeValue; part.FeedUrl = oldFeedUrl; } if (!GetTypesWithFeedSyncProfileItemPart().Contains(part.ContentType)) { updater.AddModelError("InvalidContentType", T("Please select a content type with FeedSyncProfileItemPart.")); } if (part.PublishedCount == 0) { var feedType = _feedManager.GetValidFeedType(part); if (string.IsNullOrEmpty(feedType)) { updater.AddModelError("InvalidFeedUrl", T("The given feed URL is invalid or unsupported.")); } else { part.FeedType = feedType; } } // Clearing the empty mappings so only the filled ones will be saved. part .Mappings .RemoveAll(mapping => string.IsNullOrEmpty(mapping.FeedMapping) || string.IsNullOrEmpty(mapping.ContentItemStorageMapping)); var invalidFeedMapping = false; foreach (var mapping in part.Mappings) { mapping.FeedMapping = mapping.FeedMapping.Trim(); if (mapping.FeedMapping.Any(char.IsWhiteSpace)) { invalidFeedMapping = true; updater. AddModelError( "InvalidFeedMapping", T("The given feed mapping: \"{0}\" is invalid because it contains a whitespace character.", mapping.FeedMapping)); } } if (!invalidFeedMapping) { part.MappingsSerialized = _jsonConverter.Serialize(part.Mappings); } if (part.PublishedCount == 0) { _notifier.Information(T("Please don't forget to save again after filling out the required fields!")); } } return(Editor(part, shapeHelper)); }