Files
hrynco-notification-service/HrynCo.NotificationService.Web/Controllers/Admin/ViewModels/EmailTemplateLanguageEditViewModel.cs
T
agrynco 5a465d7257 fix(admin): show template language status in editor
Center action controls and adjust template editor field heights.

Ref: IT-1601
2026-10-17 23:14:53 +03:00

32 lines
1.5 KiB
C#

using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.ModelBinding;
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; } = "";
[BindNever]
public bool IsPresent { 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)]);
}
}