From 9203c69cc6f6fa5699d8a03d8d7989c157fcd33f Mon Sep 17 00:00:00 2001 From: mohammadKarimi Date: Tue, 9 Jan 2024 12:55:09 +0330 Subject: [PATCH] Use the overloading mechanism instead of the optional parameters --- .../Common/Interfaces/IApplicationDbContext.cs | 12 ++++++++---- .../Context/ApplicationDbContext.cs | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/SwiftLink.Application/Common/Interfaces/IApplicationDbContext.cs b/src/SwiftLink.Application/Common/Interfaces/IApplicationDbContext.cs index d6d71dd..a7ed3d4 100644 --- a/src/SwiftLink.Application/Common/Interfaces/IApplicationDbContext.cs +++ b/src/SwiftLink.Application/Common/Interfaces/IApplicationDbContext.cs @@ -1,18 +1,22 @@ -using SwiftLink.Domain.Common; - -namespace SwiftLink.Application.Common.Interfaces; +namespace SwiftLink.Application.Common.Interfaces; /// /// This interface facilitates communication between the application layer, infrastructure, and the DbContext. /// public interface IApplicationDbContext { + /// + /// Save all entities in to database. + /// + /// + public Task SaveChangesAsync(); + /// /// Save all entities in to database. /// /// /// - public Task SaveChangesAsync(CancellationToken cancellationToken = default); + public Task SaveChangesAsync(CancellationToken cancellationToken); DbSet Set() where TEntity : class; } diff --git a/src/SwiftLink.Infrastructure/Context/ApplicationDbContext.cs b/src/SwiftLink.Infrastructure/Context/ApplicationDbContext.cs index beebf0a..cd8960e 100644 --- a/src/SwiftLink.Infrastructure/Context/ApplicationDbContext.cs +++ b/src/SwiftLink.Infrastructure/Context/ApplicationDbContext.cs @@ -22,7 +22,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) relationship.DeleteBehavior = DeleteBehavior.NoAction; } - public new async Task SaveChangesAsync(CancellationToken cancellationToken = default) + public async Task SaveChangesAsync() + => await SaveChangesAsync(default); + + public new async Task SaveChangesAsync(CancellationToken cancellationToken) { try {