Skip to content

Instantly share code, notes, and snippets.

@sitefinitySDK
Created October 25, 2024 23:12
Show Gist options
  • Save sitefinitySDK/2eda36581694e97617e91eadc7d5efa4 to your computer and use it in GitHub Desktop.
Save sitefinitySDK/2eda36581694e97617e91eadc7d5efa4 to your computer and use it in GitHub Desktop.
using System.Threading.Tasks;
using Progress.Sitefinity.AspNetCore.Configuration;
using Progress.Sitefinity.RestSdk;
using Progress.Sitefinity.AspNetCore.Widgets.Models.ContentBlock;
using Progress.Sitefinity.AspNetCore.Widgets.ViewComponents.Common;
using Renderer.ViewModels;
using Renderer.Entities;
namespace Renderer.Models
{
/// <summary>
/// Extended model for the ContentBlock view component.
/// </summary>
public class ExtendedContentBlockModel : ContentBlockModel
{
/// <summary>
/// Initializes a new instance of the <see cref="ExtendedContentBlockModel"/> class.
/// </summary>
/// <param name="restClient">The HTTP client.</param>
/// <param name="styles">The style classes provider.</param>
public ExtendedContentBlockModel(IRestClient restClient, IStyleClassesProvider styles)
: base(restClient, styles)
{
}
/// <summary>
/// Initializes the view model.
/// </summary>
/// <param name="context">The context.</param>
/// <returns>The view model.</returns>
public override async Task<ContentBlockViewModel> InitializeViewModel(ContentBlockEntity entity)
{
var viewModel = await base.InitializeViewModel(entity).ConfigureAwait(false);
return new ExtendedContentBlockViewModel(viewModel)
{
ModifiedContent = viewModel.Content + (entity as ExtendedContentBlockEntity).TextToAppend
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment