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:
+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)]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user