implementato modulo HR
This commit is contained in:
@@ -3,6 +3,7 @@ using Zentral.Domain.Entities.Warehouse;
|
||||
using Zentral.Domain.Entities.Purchases;
|
||||
using Zentral.Domain.Entities.Sales;
|
||||
using Zentral.Domain.Entities.Production;
|
||||
using Zentral.Domain.Entities.HR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Zentral.Infrastructure.Data;
|
||||
@@ -86,10 +87,70 @@ public class ZentralDbContext : DbContext
|
||||
public DbSet<ProductionOrderPhase> ProductionOrderPhases => Set<ProductionOrderPhase>();
|
||||
public DbSet<MrpSuggestion> MrpSuggestions => Set<MrpSuggestion>();
|
||||
|
||||
// Personale module entities
|
||||
public DbSet<Dipendente> Dipendenti => Set<Dipendente>();
|
||||
public DbSet<Contratto> Contratti => Set<Contratto>();
|
||||
public DbSet<Assenza> Assenze => Set<Assenza>();
|
||||
public DbSet<Pagamento> Pagamenti => Set<Pagamento>();
|
||||
public DbSet<Rimborso> Rimborsi => Set<Rimborso>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
// ===============================================
|
||||
// PERSONALE MODULE ENTITIES
|
||||
// ===============================================
|
||||
|
||||
modelBuilder.Entity<Dipendente>(entity =>
|
||||
{
|
||||
entity.ToTable("Dipendenti");
|
||||
entity.HasIndex(e => e.CodiceFiscale).IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Contratto>(entity =>
|
||||
{
|
||||
entity.ToTable("Contratti");
|
||||
entity.Property(e => e.RetribuzioneLorda).HasPrecision(18, 2);
|
||||
|
||||
entity.HasOne(e => e.Dipendente)
|
||||
.WithMany(d => d.Contratti)
|
||||
.HasForeignKey(e => e.DipendenteId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Assenza>(entity =>
|
||||
{
|
||||
entity.ToTable("Assenze");
|
||||
|
||||
entity.HasOne(e => e.Dipendente)
|
||||
.WithMany(d => d.Assenze)
|
||||
.HasForeignKey(e => e.DipendenteId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Pagamento>(entity =>
|
||||
{
|
||||
entity.ToTable("Pagamenti");
|
||||
entity.Property(e => e.ImportoNetto).HasPrecision(18, 2);
|
||||
|
||||
entity.HasOne(e => e.Dipendente)
|
||||
.WithMany(d => d.Pagamenti)
|
||||
.HasForeignKey(e => e.DipendenteId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Rimborso>(entity =>
|
||||
{
|
||||
entity.ToTable("Rimborsi");
|
||||
entity.Property(e => e.Importo).HasPrecision(18, 2);
|
||||
|
||||
entity.HasOne(e => e.Dipendente)
|
||||
.WithMany(d => d.Rimborsi)
|
||||
.HasForeignKey(e => e.DipendenteId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
// Cliente
|
||||
modelBuilder.Entity<Cliente>(entity =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user