-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerCreatedDomainEventHandler.cs
More file actions
40 lines (35 loc) · 1.7 KB
/
Copy pathCustomerCreatedDomainEventHandler.cs
File metadata and controls
40 lines (35 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// MIT-License
// Copyright BridgingIT GmbH - All Rights Reserved
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file at https://github.com/bridgingit/bitdevkit/license
namespace BridgingIT.DevKit.Examples.GettingStarted.Modules.CoreModule.Application;
using BridgingIT.DevKit.Domain;
using BridgingIT.DevKit.Examples.GettingStarted.Modules.CoreModule.Domain.Events;
/// <summary>
/// Handles <see cref="CustomerCreatedDomainEvent"/> notifications.
/// Triggered whenever a new <see cref="Domain.Model.Customer"/> is created.
/// Extend <see cref="Process"/> with integration, logging, or side-effects.
/// </summary>
/// <remarks>
/// Initializes a new instance of the handler with logging support.
/// </remarks>
/// <param name="loggerFactory">Factory used for creating loggers.</param>
public class CustomerCreatedDomainEventHandler(ILoggerFactory loggerFactory)
: DomainEventHandlerBase<CustomerCreatedDomainEvent>(loggerFactory)
{
/// <summary>
/// Determines whether this handler can handle the given event.
/// Returns <c>true</c> unconditionally in this template.
/// </summary>
public override bool CanHandle(CustomerCreatedDomainEvent notification) => true;
/// <summary>
/// Processes the <see cref="CustomerCreatedDomainEvent"/>.
/// Add custom logic here (e.g., start workflows, send welcome mails).
/// </summary>
public override Task Process(CustomerCreatedDomainEvent notification, CancellationToken cancellationToken)
{
// implement event reaction logic (audit, notify, etc.)
this.Logger.LogInformation("CustomerCreatedDomainEvent handled in Application");
return Task.CompletedTask;
}
}