ModelAsync<TModel>(IRedaktContext, string, Nullable<CultureInfo>)

Gets the view model for the specified node id and culture. Returns null if the content model cannot be cast to TModel.

public static async ValueTask<INodeViewModel<TModel>> ModelAsync<TModel>(IRedaktContext context, string nodeId, Nullable<CultureInfo> forCulture)
Returns:
ValueTask<INodeViewModel<TModel>>

Parameters

The current IRedaktContext.

nodeId string

The node id to get the view model for.

forCulture Nullable<CultureInfo>

The culture for the page, or null to use the current request culture.

Type Parameters

TModel

The view model type. Must implement IContentType.

ModelAsync<TModel>(IRedaktContext, Link, Nullable<CultureInfo>)

Gets the view model for the specified link and culture. Returns null if the content model cannot be cast to TModel.

public static async ValueTask<INodeViewModel<TModel>> ModelAsync<TModel>(IRedaktContext context, Link link, Nullable<CultureInfo> forCulture)
Returns:
ValueTask<INodeViewModel<TModel>>

Parameters

The current IRedaktContext.

link Link

The link object to get the view model for.

forCulture Nullable<CultureInfo>

The culture for the page, or null to use the current request culture.

Type Parameters

TModel

The view model type. Must implement IContentType.

ModelAsync<TModel>(IRedaktContext, IPublishedContent)

Gets the view model for the specified published content object. Returns null if the content model cannot be cast to TModel.

public static async ValueTask<INodeViewModel<TModel>> ModelAsync<TModel>(IRedaktContext context, IPublishedContent publishedContent)
Returns:
ValueTask<INodeViewModel<TModel>>

Parameters

The current IRedaktContext.

publishedContent IPublishedContent

The published content object to get the view model for.

Type Parameters

TModel

The view model type. Must implement IContentType.

In this article