Remove unnecessary method
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
public class FrancescosRecipesWorldDbContext : IdentityDbContext<IdentityUser>
|
||||
public class FrancescosRecipesWorldDbContext : DbContext
|
||||
{
|
||||
public FrancescosRecipesWorldDbContext(DbContextOptions<FrancescosRecipesWorldDbContext> options)
|
||||
: base(options)
|
||||
@@ -22,26 +22,5 @@
|
||||
public DbSet<Instruction> Instructions => Set<Instruction>();
|
||||
public DbSet<Recipe> Recipes => Set<Recipe>();
|
||||
public DbSet<RecipeIngredient> RecipeIngredients => Set<RecipeIngredient>();
|
||||
|
||||
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
foreach (var entry in ChangeTracker.Entries())
|
||||
{
|
||||
if (entry.Entity is ITimeStampedEntity timeStampedEntity)
|
||||
{
|
||||
switch (entry.State)
|
||||
{
|
||||
case EntityState.Added:
|
||||
timeStampedEntity.CreatedAt = DateTime.UtcNow;
|
||||
break;
|
||||
case EntityState.Modified:
|
||||
timeStampedEntity.ModifiedAt = DateTime.UtcNow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user