diff --git a/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEnvelopeTemplateCommand.cs b/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEnvelopeTemplateCommand.cs
index 38926dd6..29a51f19 100644
--- a/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEnvelopeTemplateCommand.cs
+++ b/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEnvelopeTemplateCommand.cs
@@ -20,4 +20,4 @@ namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Reset;
/// 8 - DocumentRejected_REC (Für den ablehnenden Empfänger): Mail an den ablehnenden Empfänger, wenn das Dokument abgelehnt wird.
/// 9 - DocumentRejected_REC_2 (Für sonstige Empfänger): Mail an andere Empfänger (Brief), wenn das Dokument abgelehnt wird.
///
-public record ResetEnvelopeTemplateCommand(int? Id, Constants.EmailTemplateType? Type) : EmailTemplateQuery(Id, Type), IRequest;
+public record ResetEnvelopeTemplateCommand(int? Id = null, Constants.EmailTemplateType? Type = null) : EmailTemplateQuery(Id, Type), IRequest;
diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/EmailTemplateController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/EmailTemplateController.cs
index 0e90bfd7..fd93c584 100644
--- a/EnvelopeGenerator.GeneratorAPI/Controllers/EmailTemplateController.cs
+++ b/EnvelopeGenerator.GeneratorAPI/Controllers/EmailTemplateController.cs
@@ -8,6 +8,8 @@ using Microsoft.AspNetCore.Mvc;
using EnvelopeGenerator.Application.Contracts.Repositories;
using EnvelopeGenerator.Application.DTOs;
using MediatR;
+using System.Threading.Tasks;
+using DigitalData.UserManager.Application.Services;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
@@ -102,19 +104,27 @@ public class EmailTemplateController : ControllerBase
/// Wenn der Benutzer nicht authentifiziert ist.
/// Wenn die gesuchte Abfrage nicht gefunden wird.
[HttpPut]
- public IActionResult Update([FromQuery] EmailTemplateQuery email, [FromBody] UpdateEmailTemplateCommand? update = null)
+ public async Task Update([FromQuery] EmailTemplateQuery email, [FromBody] UpdateEmailTemplateCommand? update = null)
{
- if (update is null)
+ try
{
- var reset = _mapper.Map(email);
- // Logic for resetting the email template
- }
- else
- {
- update.EmailTemplateQuery = email;
- // Logic for updating the email template
- }
+ if (update is null)
+ {
+ var reset = _mapper.Map(email);
+ await _mediator.Send(new ResetEnvelopeTemplateCommand(email?.Id, email?.Type));
+ return Ok();
+ }
+ else
+ {
+ update.EmailTemplateQuery = email;
+ // Logic for updating the email template
+ }
- return Ok(); // Placeholder for actual implementation
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "An unexpected error occurred. {message}", ex.Message);
+ return new StatusCodeResult(StatusCodes.Status500InternalServerError);
+ }
}
}