-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94b5fb9
commit 4debb96
Showing
8 changed files
with
102 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
VirtuaMind.Infrastructure/Persistence/VirtualMindDbContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using VirtualMind.Application.Interfaces; | ||
using VirtualMind.Domain.Entities; | ||
|
||
namespace VirtuaMind.Infrastructure.Persistence | ||
{ | ||
public class VirtualMindDbContext : DbContext, IVirtualMindDbContext | ||
{ | ||
public VirtualMindDbContext(DbContextOptions options): base(options) | ||
{ | ||
} | ||
|
||
public DbSet<Operation> Operations { get; set; } | ||
|
||
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken()) | ||
{ | ||
foreach (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<AuditableEntity> entry in ChangeTracker.Entries<AuditableEntity>()) | ||
{ | ||
switch (entry.State) | ||
{ | ||
case EntityState.Added: | ||
entry.Entity.Created = DateTime.Now; | ||
break; | ||
} | ||
} | ||
|
||
var result = await base.SaveChangesAsync(cancellationToken); | ||
|
||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
VirtualMind.Application/Interfaces/IVirtualMindDbContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using VirtualMind.Domain.Entities; | ||
|
||
namespace VirtualMind.Application.Interfaces | ||
{ | ||
public interface IVirtualMindDbContext | ||
{ | ||
DbSet<Operation> Operations { get; set; } | ||
|
||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |