Skip to content

Commit 20d6930

Browse files
authored
Merge pull request #64 from A-Programmer/Fix-Domain-Events
Fix domain events
2 parents f807a16 + 7233497 commit 20d6930

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ public class WeeklyNewsletterJob
183183

184184
---
185185

186+
## How to push new version
187+
1. Implement changes
188+
2. Add and Commit changes in git
189+
3. Tag the changes `git tag vX.Y.Z`
190+
4. Push the changes `git push`
191+
5. Create Pull Request and merge changes
192+
6. Push the tag `git push origin vX.Y.Z`
193+
186194
## 📄 License
187195

188196
Licensed under MIT.

Samples/BlogApp/Project.Application/Blog/EventHandlers/PostCreatedDomainEventHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public PostCreatedDomainEventHandler(ILogger<PostCreatedDomainEventHandler> logg
1515

1616
public Task Handle(PostCreatedDomainEvent notification, CancellationToken cancellationToken)
1717
{
18-
_logger.LogInformation("Post created:: {PostId} - {Title}", notification.PostId, notification.Title);
18+
_logger.LogInformation("Post created: {PostId} - {Title}", notification.PostId, notification.Title);
1919

2020
// Here you can add additional business logic like:
2121
// - Sending notifications

src/KSFramework/GenericRepository/IUnitOfWork.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@ public interface IUnitOfWork : IDisposable
1212
/// Saves all changes made in this unit of work to the underlying data store asynchronously.
1313
/// </summary>
1414
/// <returns>A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.</returns>
15-
Task<int> SaveChangesAsync();
15+
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
16+
17+
/// <inheritdoc cref="SaveChangesAsync(System.Threading.CancellationToken)"/>
18+
Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess,
19+
CancellationToken cancellationToken = default);
20+
21+
/// <inheritdoc cref="SaveChanges"/>
22+
int SaveChanges(bool acceptAllChangesOnSuccess);
23+
24+
/// <inheritdoc cref="SaveChanges"/>
25+
int SaveChanges();
1626

1727
/// <summary>
1828
/// Gets a generic repository for the specified entity type.

src/KSFramework/GenericRepository/UnitOfWork.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Reflection;
34
using System.Threading.Tasks;
45
using KSFramework.KSDomain.AggregatesHelper;
6+
using KSFramework.Utilities;
57
using Microsoft.EntityFrameworkCore;
8+
using Microsoft.EntityFrameworkCore.ChangeTracking;
69

710
namespace KSFramework.GenericRepository;
811

@@ -22,14 +25,32 @@ public UnitOfWork(DbContext context)
2225
_context = context;
2326
_repositories = new Dictionary<Type, object>();
2427
}
28+
public virtual int SaveChanges()
29+
{
30+
return _context.SaveChanges();
31+
}
32+
33+
public virtual int SaveChanges(bool acceptAllChangesOnSuccess)
34+
{
35+
return _context.SaveChanges(acceptAllChangesOnSuccess);
36+
}
2537

2638
/// <summary>
2739
/// Saves all changes made in this unit of work to the underlying data store asynchronously.
2840
/// </summary>
2941
/// <returns>A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.</returns>
30-
public async Task<int> SaveChangesAsync()
42+
public virtual Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default)
43+
{
44+
return _context.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);
45+
}
46+
47+
/// <summary>
48+
/// Saves all changes made in this unit of work to the underlying data store asynchronously.
49+
/// </summary>
50+
/// <returns>A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.</returns>
51+
public virtual Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
3152
{
32-
return await _context.SaveChangesAsync();
53+
return _context.SaveChangesAsync(cancellationToken);
3354
}
3455

3556
/// <summary>

0 commit comments

Comments
 (0)