Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public PostCreatedDomainEventHandler(ILogger<PostCreatedDomainEventHandler> 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
Expand Down
12 changes: 11 additions & 1 deletion src/KSFramework/GenericRepository/IUnitOfWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ public interface IUnitOfWork : IDisposable
/// Saves all changes made in this unit of work to the underlying data store asynchronously.
/// </summary>
/// <returns>A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.</returns>
Task<int> SaveChangesAsync();
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);

/// <inheritdoc cref="SaveChangesAsync(System.Threading.CancellationToken)"/>
Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess,
CancellationToken cancellationToken = default);

/// <inheritdoc cref="SaveChanges"/>
int SaveChanges(bool acceptAllChangesOnSuccess);

/// <inheritdoc cref="SaveChanges"/>
int SaveChanges();

/// <summary>
/// Gets a generic repository for the specified entity type.
Expand Down
25 changes: 23 additions & 2 deletions src/KSFramework/GenericRepository/UnitOfWork.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -22,14 +25,32 @@ public UnitOfWork(DbContext context)
_context = context;
_repositories = new Dictionary<Type, object>();
}
public virtual int SaveChanges()
{
return _context.SaveChanges();
}

public virtual int SaveChanges(bool acceptAllChangesOnSuccess)
{
return _context.SaveChanges(acceptAllChangesOnSuccess);
}

/// <summary>
/// Saves all changes made in this unit of work to the underlying data store asynchronously.
/// </summary>
/// <returns>A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.</returns>
public async Task<int> SaveChangesAsync()
public virtual Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default)
{
return _context.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);
}

/// <summary>
/// Saves all changes made in this unit of work to the underlying data store asynchronously.
/// </summary>
/// <returns>A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.</returns>
public virtual Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
{
return await _context.SaveChangesAsync();
return _context.SaveChangesAsync(cancellationToken);
}

/// <summary>
Expand Down