feat(notification): add admin rest management and deletion
Add revision-safe service and template APIs, channel mapping, and validated admin controls. Ref: IT-1601
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
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()
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user