8e81572386
Add revision-safe service and template APIs, channel mapping, and validated admin controls. Ref: IT-1601
20 lines
934 B
C#
20 lines
934 B
C#
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
|
|
|
namespace HrynCo.NotificationService.Web.Controllers.Api.Services;
|
|
|
|
internal static class NotificationServiceRequestMapping
|
|
{
|
|
public static NotificationServiceInfo Map(Guid? id, string name, IReadOnlyList<ServiceLanguageRequest>? languages, Guid revision)
|
|
{
|
|
if (languages is null || languages.Any(l => l is null))
|
|
throw new EmailTemplateWriteException("languages must be a JSON array without null elements.", false);
|
|
if (id is null && languages.Any(l => l.Id != Guid.Empty))
|
|
throw new EmailTemplateWriteException("New services cannot reference persisted language IDs.", false);
|
|
return new NotificationServiceInfo
|
|
{
|
|
Id = id ?? Guid.Empty, Name = name, Revision = revision,
|
|
Languages = languages.Select(l => new ServiceLanguageInfo { Id = l.Id, Code = l.Code }).ToList()
|
|
};
|
|
}
|
|
}
|