Enhance email template handling and documentation
- Added XML documentation to the `Handle` method in `UpdateEmailTemplateCommandHandler`. - Improved readability in `ReadEmailTemplateQueryHandler` by storing the mapped response in a variable. - Updated properties in `ReadEmailTemplateResponse` to be mutable and renamed `Type` to `Name` with a type change from `int` to `string`. - Added data annotations in `EmailTemplate` for `AddedWhen` and introduced a new nullable `ChangedWhen` property. - Included necessary using directives for data annotations in `EmailTemplate.cs`.
This commit is contained in:
parent
b15616cf53
commit
629c0d51b2
@ -24,6 +24,14 @@ public class UpdateEmailTemplateCommandHandler : IRequestHandler<UpdateEmailTemp
|
|||||||
_repository = repository;
|
_repository = repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="cancel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="InvalidOperationException"></exception>
|
||||||
|
/// <exception cref="NotFoundException"></exception>
|
||||||
public async Task Handle(UpdateEmailTemplateCommand request, CancellationToken cancel)
|
public async Task Handle(UpdateEmailTemplateCommand request, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
var temp = (request.EmailTemplateQuery?.Id is int id
|
var temp = (request.EmailTemplateQuery?.Id is int id
|
||||||
|
|||||||
@ -45,6 +45,8 @@ public class ReadEmailTemplateQueryHandler : IRequestHandler<ReadEmailTemplateQu
|
|||||||
? await _repository.ReadByNameAsync(type)
|
? await _repository.ReadByNameAsync(type)
|
||||||
: throw new InvalidOperationException("Either a valid integer ID or a valid EmailTemplateType must be provided in the request.");
|
: throw new InvalidOperationException("Either a valid integer ID or a valid EmailTemplateType must be provided in the request.");
|
||||||
|
|
||||||
return temp is null ? null : _mapper.Map<ReadEmailTemplateResponse>(temp);
|
var res = _mapper.Map<ReadEmailTemplateResponse>(temp);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,17 +8,17 @@ public class ReadEmailTemplateResponse
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Die eindeutige Kennung der E-Mail-Vorlage.
|
/// Die eindeutige Kennung der E-Mail-Vorlage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; init; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Der Typ der E-Mail-Vorlage.
|
/// Name des Typs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Type { get; init; }
|
public required string Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Das Datum und die Uhrzeit, wann die Vorlage hinzugefügt wurde.
|
/// Das Datum und die Uhrzeit, wann die Vorlage hinzugefügt wurde.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime AddedWhen { get; init; }
|
public DateTime AddedWhen { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Der Inhalt (Body) der E-Mail-Vorlage. Kann null sein.
|
/// Der Inhalt (Body) der E-Mail-Vorlage. Kann null sein.
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using DigitalData.Core.Abstractions;
|
using DigitalData.Core.Abstractions;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
@ -20,5 +21,13 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
|
|
||||||
[Column("SUBJECT", TypeName = "nvarchar(512)")]
|
[Column("SUBJECT", TypeName = "nvarchar(512)")]
|
||||||
public string? Subject { get; set; }
|
public string? Subject { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||||
|
[DefaultValue("GETDATE()")]
|
||||||
|
public DateTime AddedWhen { get; set; }
|
||||||
|
|
||||||
|
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||||
|
public DateTime? ChangedWhen { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user