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:
+11
-1
@@ -1,3 +1,4 @@
|
||||
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
||||
using HrynCo.DAL.Abstract;
|
||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||
using HrynCo.NotificationService.Services.Core;
|
||||
@@ -27,8 +28,17 @@ internal sealed class DeleteEmailTemplateHandler
|
||||
|
||||
if (template is null)
|
||||
return Failure<Unit>("Template not found.", ServiceErrorCode.NotFound);
|
||||
if (request.ExpectedVersionId is Guid expectedId && template.Id != expectedId)
|
||||
return Failure<Unit>("Template changed after you opened it. Reload before deleting.", ServiceErrorCode.Conflict);
|
||||
|
||||
await _templates.DeleteAsync(template, cancellationToken);
|
||||
try
|
||||
{
|
||||
await _templates.DeleteAsync(template, cancellationToken);
|
||||
}
|
||||
catch (EmailTemplateWriteException error)
|
||||
{
|
||||
return Failure<Unit>(error.Message, error.IsConflict ? ServiceErrorCode.Conflict : ServiceErrorCode.InvalidRequest);
|
||||
}
|
||||
|
||||
return Success(Unit.Value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user