From 1547e975e4f759dbae9cced83ea6137e3df5595b Mon Sep 17 00:00:00 2001 From: Kamran Sadin Date: Wed, 13 Aug 2025 22:47:42 +0330 Subject: [PATCH 1/2] Fix DomainEvents --- .../Blog/EventHandlers/PostCreatedDomainEventHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Samples/BlogApp/Project.Application/Blog/EventHandlers/PostCreatedDomainEventHandler.cs b/Samples/BlogApp/Project.Application/Blog/EventHandlers/PostCreatedDomainEventHandler.cs index fd67b84..df07a4b 100644 --- a/Samples/BlogApp/Project.Application/Blog/EventHandlers/PostCreatedDomainEventHandler.cs +++ b/Samples/BlogApp/Project.Application/Blog/EventHandlers/PostCreatedDomainEventHandler.cs @@ -15,7 +15,7 @@ public PostCreatedDomainEventHandler(ILogger logg public Task Handle(PostCreatedDomainEvent notification, CancellationToken cancellationToken) { - _logger.LogInformation("Post created:: {PostId} - {Title}", notification.PostId, notification.Title); + _logger.LogInformation("Post created: {PostId} - {Title}", notification.PostId, notification.Title); // Here you can add additional business logic like: // - Sending notifications From 7233497f994f819b69f4a2024ebf6456f586e85a Mon Sep 17 00:00:00 2001 From: Kamran Sadin Date: Thu, 6 Nov 2025 15:03:19 +0330 Subject: [PATCH 2/2] Add other SaveChange methods to IUnitOfWork and UnitOfWork as virtual method --- README.md | 8 ++++++ .../GenericRepository/IUnitOfWork.cs | 12 ++++++++- .../GenericRepository/UnitOfWork.cs | 25 +++++++++++++++++-- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6cdbe94..ee9df04 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,14 @@ public class WeeklyNewsletterJob --- +## How to push new version +1. Implement changes +2. Add and Commit changes in git +3. Tag the changes `git tag vX.Y.Z` +4. Push the changes `git push` +5. Create Pull Request and merge changes +6. Push the tag `git push origin vX.Y.Z` + ## 📄 License Licensed under MIT. \ No newline at end of file diff --git a/src/KSFramework/GenericRepository/IUnitOfWork.cs b/src/KSFramework/GenericRepository/IUnitOfWork.cs index 516108e..6f7e867 100644 --- a/src/KSFramework/GenericRepository/IUnitOfWork.cs +++ b/src/KSFramework/GenericRepository/IUnitOfWork.cs @@ -12,7 +12,17 @@ public interface IUnitOfWork : IDisposable /// Saves all changes made in this unit of work to the underlying data store asynchronously. /// /// A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database. - Task SaveChangesAsync(); + Task SaveChangesAsync(CancellationToken cancellationToken = default); + + /// + Task SaveChangesAsync(bool acceptAllChangesOnSuccess, + CancellationToken cancellationToken = default); + + /// + int SaveChanges(bool acceptAllChangesOnSuccess); + + /// + int SaveChanges(); /// /// Gets a generic repository for the specified entity type. diff --git a/src/KSFramework/GenericRepository/UnitOfWork.cs b/src/KSFramework/GenericRepository/UnitOfWork.cs index 57ef87c..a5e21d6 100644 --- a/src/KSFramework/GenericRepository/UnitOfWork.cs +++ b/src/KSFramework/GenericRepository/UnitOfWork.cs @@ -1,8 +1,11 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Threading.Tasks; using KSFramework.KSDomain.AggregatesHelper; +using KSFramework.Utilities; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking; namespace KSFramework.GenericRepository; @@ -22,14 +25,32 @@ public UnitOfWork(DbContext context) _context = context; _repositories = new Dictionary(); } + public virtual int SaveChanges() + { + return _context.SaveChanges(); + } + + public virtual int SaveChanges(bool acceptAllChangesOnSuccess) + { + return _context.SaveChanges(acceptAllChangesOnSuccess); + } /// /// Saves all changes made in this unit of work to the underlying data store asynchronously. /// /// A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database. - public async Task SaveChangesAsync() + public virtual Task SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default) + { + return _context.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken); + } + + /// + /// Saves all changes made in this unit of work to the underlying data store asynchronously. + /// + /// A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database. + public virtual Task SaveChangesAsync(CancellationToken cancellationToken = default) { - return await _context.SaveChangesAsync(); + return _context.SaveChangesAsync(cancellationToken); } ///