feat(templates): add service language template management
Add normalized service and template catalogs, scoped administration, migration, validation, and regression coverage. Ref: IT-1601
This commit is contained in:
+7
-19
@@ -2,32 +2,20 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace HrynCo.NotificationService.Web.Controllers.Admin.ViewModels;
|
||||
|
||||
public class EmailTemplateEditViewModel
|
||||
public sealed class EmailTemplateEditViewModel
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public Guid ServiceId { get; set; }
|
||||
public Guid Revision { get; set; }
|
||||
[Required, StringLength(100)]
|
||||
public string ServiceName { get; set; } = "";
|
||||
|
||||
[Required]
|
||||
[Required, StringLength(100)]
|
||||
public string Key { get; set; } = "";
|
||||
|
||||
[Required]
|
||||
public string LanguageCode { get; set; } = "";
|
||||
|
||||
[Required]
|
||||
public string Subject { get; set; } = "";
|
||||
|
||||
[Required]
|
||||
public string HtmlBody { get; set; } = "";
|
||||
|
||||
public string TextBody { get; set; } = "";
|
||||
|
||||
// JSON array: [{"name":"UserName","required":true}, ...]
|
||||
public string VariablesJson { get; set; } = "[]";
|
||||
public string? ServiceNameFilter { get; set; }
|
||||
public List<EmailTemplateLanguageEditViewModel> Languages { get; set; } = [];
|
||||
public int ActiveLanguageIndex { get; set; }
|
||||
public string? KeyFilter { get; set; }
|
||||
|
||||
public bool IsNew => Id == null;
|
||||
public string PageTitle => IsNew ? "Create Email Template" : "Edit Email Template";
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace HrynCo.NotificationService.Web.Controllers.Admin.ViewModels;
|
||||
|
||||
public sealed class EmailTemplateLanguageEditViewModel : IValidatableObject
|
||||
{
|
||||
[Required, StringLength(10)]
|
||||
public string LanguageCode { get; set; } = "";
|
||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||
public string Subject { get; set; } = "";
|
||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||
public string HtmlBody { get; set; } = "";
|
||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||
public string TextBody { get; set; } = "";
|
||||
public bool HasContent => !string.IsNullOrWhiteSpace(Subject) || !string.IsNullOrWhiteSpace(HtmlBody) || !string.IsNullOrWhiteSpace(TextBody);
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (!HasContent)
|
||||
yield break;
|
||||
if (string.IsNullOrWhiteSpace(Subject))
|
||||
yield return new ValidationResult("The Subject field is required for a populated language.", [nameof(Subject)]);
|
||||
if (string.IsNullOrWhiteSpace(HtmlBody))
|
||||
yield return new ValidationResult("The HtmlBody field is required for a populated language.", [nameof(HtmlBody)]);
|
||||
if (string.IsNullOrWhiteSpace(TextBody))
|
||||
yield return new ValidationResult("The TextBody field is required for a populated language.", [nameof(TextBody)]);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
||||
|
||||
namespace HrynCo.NotificationService.Web.Controllers.Admin.ViewModels;
|
||||
|
||||
public sealed class NotificationServiceEditViewModel
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public Guid Revision { get; set; }
|
||||
[Required, StringLength(100)]
|
||||
public string Name { get; set; } = "";
|
||||
public List<ServiceLanguageInfo> Languages { get; set; } = [];
|
||||
public bool IsNew => Id is null;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
namespace HrynCo.NotificationService.Web.Controllers.Admin.ViewModels;
|
||||
|
||||
public sealed class ServiceLanguageDeleteViewModel
|
||||
{
|
||||
public Guid ServiceId { get; set; }
|
||||
public Guid LanguageId { get; set; }
|
||||
public string ServiceName { get; set; } = "";
|
||||
public string Code { get; set; } = "";
|
||||
public Guid Revision { get; set; }
|
||||
public int VersionCount { get; set; }
|
||||
public bool ConfirmDelete { get; set; }
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
||||
|
||||
namespace HrynCo.NotificationService.Web.Controllers.Admin.ViewModels;
|
||||
|
||||
public sealed class ServiceTemplatesViewModel
|
||||
{
|
||||
public required NotificationServiceInfo Service { get; init; }
|
||||
public string? KeyFilter { get; init; }
|
||||
public IReadOnlyList<EmailTemplateDefinition> Definitions { get; set; } = [];
|
||||
}
|
||||
Reference in New Issue
Block a user