-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
040cb09
commit 10355db
Showing
643 changed files
with
16,827 additions
and
17,503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 28 additions & 35 deletions
63
src/1-BuildingBlocks/Application/Behaviors/EventStoringBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,49 @@ | ||
using MediatR; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using TaskoMask.BuildingBlocks.Application.Commands; | ||
using TaskoMask.BuildingBlocks.Domain.Events; | ||
|
||
namespace TaskoMask.BuildingBlocks.Application.Behaviors | ||
namespace TaskoMask.BuildingBlocks.Application.Behaviors; | ||
|
||
/// <summary> | ||
/// Each command must have at least one event to save its changes in event store | ||
/// So this notification handler act as a behavior and makes it easy to store events without repeating the creation of event handler | ||
/// However events can have other handlers to do other things like sending an email or update some other entities, etc. | ||
/// </summary> | ||
public class EventStoringBehavior : INotificationHandler<DomainEvent> | ||
{ | ||
/// <summary> | ||
/// Each command must have at least one event to save its changes in event store | ||
/// So this notification handler act as a behavior and makes it easy to store events without repeating the creation of event handler | ||
/// However events can have other handlers to do other things like sending an email or update some other entities, etc. | ||
/// </summary> | ||
public class EventStoringBehavior : INotificationHandler<DomainEvent> | ||
{ | ||
#region Fields | ||
#region Fields | ||
|
||
private readonly IEventStoreService _eventStore; | ||
private readonly IEventStoreService _eventStore; | ||
|
||
#endregion | ||
#endregion | ||
|
||
#region Ctors | ||
#region Ctors | ||
|
||
|
||
public EventStoringBehavior(IEventStoreService eventStore) | ||
{ | ||
_eventStore = eventStore; | ||
} | ||
public EventStoringBehavior(IEventStoreService eventStore) | ||
{ | ||
_eventStore = eventStore; | ||
} | ||
|
||
#endregion | ||
#endregion | ||
|
||
#region Public Methods | ||
#region Public Methods | ||
|
||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public async Task Handle(DomainEvent request, CancellationToken cancellationToken) | ||
{ | ||
await _eventStore.SaveAsync(request); | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public async Task Handle(DomainEvent request, CancellationToken cancellationToken) | ||
{ | ||
await _eventStore.SaveAsync(request); | ||
} | ||
|
||
#endregion | ||
#endregion | ||
|
||
#region Private Methods | ||
#region Private Methods | ||
|
||
|
||
|
||
#endregion | ||
} | ||
#endregion | ||
} |
Oops, something went wrong.