Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
This looks like it's a base viewmodel for any of the view models in your site.It also looks like maybe IPageViewModel<T> has a restriction to SitePageData which is likely your base page model with base properties. So you'll want change this class (DefaultPageViewModel<T>) from PageData to SitePageData
Then if you're createing a search page I'd expect the following
This should all work. Just make sure you're interface and classes generic parameter type restrictions match.
Also as a point on design, your ViewModel should not be setting properties such as
CurrentPage = currentPage;
Section = ContentExtensions.GetSection(currentPage.ContentLink);
The viewmodel should be kept clean, those properties should be setup by the controller or ideally a factory/service for your ViewModel generation.
public class DefaultPageViewModel<T> : IPageViewModel<T> where T : PageData
{
public DefaultPageViewModel(T currentPage)
{
CurrentPage = currentPage;
Section = ContentExtensions.GetSection(currentPage.ContentLink);
}
public T CurrentPage { get; set; }
public IContent Section { get; set; }
}