Refactor email handling for improved structure
Refactored `Email` and `SendingEmailEvent` to use `record` types, consolidating email-related data into the `Email` class. Updated `SendEmailCommand` to return a `Guid` and simplified mapping logic in `EmailMappingProfile`. Adjusted `SendEmailCommandHandler` to construct `SendingEmailEvent` manually. Updated `SendingEmailConsumer`, `EmailsController`, and `EmailSender` to reflect the new structure. Removed the old `Email` implementation. Improved logging to reference the `Mail` property. Revised tests to align with the new structure, ensuring immutability and better separation of concerns.
This commit is contained in:
@@ -23,11 +23,11 @@ public class EmailsController(IMediator mediator) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> SendEmail([FromBody] SendEmailCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var sendingEmailEvent = await mediator.Send(command, cancellationToken);
|
||||
var eventId = await mediator.Send(command, cancellationToken);
|
||||
|
||||
return Accepted(new
|
||||
{
|
||||
sendingEmailEvent.Id,
|
||||
Id = eventId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user