Remove unnecessary method

This commit is contained in:
Francesco D'Amico
2025-01-08 11:28:46 +01:00
parent 1f2344eabf
commit 53bf98ece6
@@ -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);
}
}
}