Browse Source

Decreased the duplication

pull/13499/head
malik masis 4 years ago
parent
commit
5cbc145271
  1. 7
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/IContent.cs
  2. 2
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/PageDto.cs
  3. 2
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/ContentFragment.cshtml
  4. 16
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/ContentFragmentViewComponent.cs

7
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/IContent.cs

@ -0,0 +1,7 @@
using System.Collections.Generic;
namespace Volo.CmsKit.Contents;
public interface IContent
{
public List<ContentFragment> ContentFragments { get; set; }
}

2
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/PageDto.cs

@ -5,7 +5,7 @@ using Volo.Abp.Application.Dtos;
namespace Volo.CmsKit.Contents;
[Serializable]
public class PageDto : EntityDto<Guid>
public class PageDto : EntityDto<Guid>, IContent
{
public string Title { get; set; }

2
modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/ContentFragment.cshtml

@ -7,7 +7,7 @@
@inject IMarkdownToHtmlRenderer MarkdownRenderer
@foreach (var contentFragment in Model.PageDto.ContentFragments)
@foreach (var contentFragment in Model.ContentDto.ContentFragments)
{
if (contentFragment.Type == "Markdown")
{

16
modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/ContentFragmentViewComponent.cs

@ -1,26 +1,22 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Web.Contents;
[ViewComponent(Name = "ContentFragment")]
[Widget(
AutoInitialize = true
)]
[ViewComponent(Name = "ContentFragment")]
public class ContentFragmentViewComponent : ViewComponent
public class ContentFragmentViewComponent : AbpViewComponent
{
public PageDto PageDto { get; set; }
public ContentFragmentViewComponent()
{
PageDto = new();
}
public IContent ContentDto { get; set; }
public virtual async Task<IViewComponentResult> InvokeAsync(PageDto pageDto)
public virtual async Task<IViewComponentResult> InvokeAsync(IContent contentDto)
{
return View("~/Contents/ContentFragment.cshtml", new ContentFragmentViewComponent() { PageDto = pageDto });
return View("~/Contents/ContentFragment.cshtml", new ContentFragmentViewComponent() { ContentDto = contentDto });
}
}

Loading…
Cancel
Save