mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
- Fixing 16254: Make BuildEditorModel resilient to invalid content item ID
--HG-- branch : dev
This commit is contained in:
@@ -166,15 +166,25 @@ namespace Orchard.ContentManagement {
|
|||||||
/* Display and editor convenience extension methods */
|
/* Display and editor convenience extension methods */
|
||||||
|
|
||||||
public static ContentItemViewModel<T> BuildDisplayModel<T>(this IContentManager manager, int id, string displayType) where T : class, IContent {
|
public static ContentItemViewModel<T> BuildDisplayModel<T>(this IContentManager manager, int id, string displayType) where T : class, IContent {
|
||||||
return manager.BuildDisplayModel(manager.Get<T>(id), displayType);
|
var content = manager.Get<T>(id);
|
||||||
|
if (content == null)
|
||||||
|
return null;
|
||||||
|
return manager.BuildDisplayModel(content, displayType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ContentItemViewModel<T> BuildEditorModel<T>(this IContentManager manager, int id) where T : class, IContent {
|
public static ContentItemViewModel<T> BuildEditorModel<T>(this IContentManager manager, int id) where T : class, IContent {
|
||||||
return manager.BuildEditorModel(manager.Get<T>(id));
|
var content = manager.Get<T>(id);
|
||||||
|
if (content == null)
|
||||||
|
return null;
|
||||||
|
return manager.BuildEditorModel(content);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ContentItemViewModel<T> UpdateEditorModel<T>(this IContentManager manager, int id, IUpdateModel updater) where T : class, IContent {
|
public static ContentItemViewModel<T> UpdateEditorModel<T>(this IContentManager manager, int id, IUpdateModel updater) where T : class, IContent {
|
||||||
return manager.UpdateEditorModel(manager.Get<T>(id), updater);
|
var content = manager.Get<T>(id);
|
||||||
|
if (content == null)
|
||||||
|
return null;
|
||||||
|
return manager.UpdateEditorModel(content, updater);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user