sozsoft-platform/api/src/Sozsoft.Platform.Domain/BackgroundWorkers/PlatformTemplateManager.cs
Sedat Öztürk 429227df1d Initial
2026-02-24 23:44:16 +03:00

33 lines
1.1 KiB
C#

using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Volo.Abp.TextTemplating;
using Volo.Abp.TextTemplating.Razor;
namespace Sozsoft.Platform.BackgroundWorkers;
public class PlatformTemplateManager : DomainService
{
private readonly ITemplateDefinitionManager templateDefinitionManager;
public PlatformTemplateManager(ITemplateDefinitionManager templateDefinitionManager)
{
this.templateDefinitionManager = templateDefinitionManager;
}
public async Task AddOrUpdateTemplateAsync(string name, string template)
{
var templateDefinition = await templateDefinitionManager.GetOrNullAsync(name);
if (templateDefinition == null)
{
templateDefinition = new TemplateDefinition(name)
.WithRazorEngine()
.WithProperty(PropertyTemplateContentContributor.PropertyContentPropertyName, template);
PlatformTemplateDynamicStore.TemplateDefinitions.Add(name, templateDefinition);
}
else
{
templateDefinition.WithProperty(PropertyTemplateContentContributor.PropertyContentPropertyName, template);
}
}
}