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/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 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); } ///