Implentata scansione barcode e lista articoli nel form scheda
This commit is contained in:
@@ -8,6 +8,7 @@ public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(op
|
||||
{
|
||||
public DbSet<Ispezione> Ispezioni => Set<Ispezione>();
|
||||
public DbSet<Scheda> Schede => Set<Scheda>();
|
||||
public DbSet<SchedaArticolo> SchedaArticoli => Set<SchedaArticolo>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -15,7 +16,7 @@ public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(op
|
||||
|
||||
modelBuilder.Entity<Ispezione>()
|
||||
.HasKey(x => new { x.CodMdep, x.Data, x.Rilevatore });
|
||||
|
||||
|
||||
modelBuilder.Entity<Scheda>()
|
||||
.HasOne(x => x.Ispezione)
|
||||
.WithMany(x => x.Schede)
|
||||
@@ -31,5 +32,15 @@ public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(op
|
||||
v => JsonSerializer.Serialize(v, (JsonSerializerOptions?)null),
|
||||
v => JsonSerializer.Deserialize<List<string>>(v, (JsonSerializerOptions?)null) ?? new List<string>()
|
||||
);
|
||||
|
||||
modelBuilder.Entity<SchedaArticolo>()
|
||||
.HasOne(a => a.Scheda)
|
||||
.WithMany(s => s.Articoli)
|
||||
.HasForeignKey(a => a.SchedaId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<SchedaArticolo>()
|
||||
.HasIndex(a => new { a.SchedaId, a.Barcode })
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user