Skip to content

Commit

Permalink
Use the overloading mechanism instead of the optional parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadKarimi committed Jan 9, 2024
1 parent 372b882 commit 9203c69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
using SwiftLink.Domain.Common;

namespace SwiftLink.Application.Common.Interfaces;
namespace SwiftLink.Application.Common.Interfaces;

/// <summary>
/// This interface facilitates communication between the application layer, infrastructure, and the DbContext.
/// </summary>
public interface IApplicationDbContext
{
/// <summary>
/// Save all entities in to database.
/// </summary>
/// <returns></returns>
public Task<Result> SaveChangesAsync();

/// <summary>
/// Save all entities in to database.
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public Task<Result> SaveChangesAsync(CancellationToken cancellationToken = default);
public Task<Result> SaveChangesAsync(CancellationToken cancellationToken);

DbSet<TEntity> Set<TEntity>() where TEntity : class;
}
5 changes: 4 additions & 1 deletion src/SwiftLink.Infrastructure/Context/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
relationship.DeleteBehavior = DeleteBehavior.NoAction;
}

public new async Task<Result> SaveChangesAsync(CancellationToken cancellationToken = default)
public async Task<Result> SaveChangesAsync()
=> await SaveChangesAsync(default);

public new async Task<Result> SaveChangesAsync(CancellationToken cancellationToken)
{
try
{
Expand Down

0 comments on commit 9203c69

Please sign in to comment.