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? 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() }; } }