using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using OmsorgCore.Domain.Entities;

namespace OmsorgCore.Infrastructure.Persistence.Configurations;

public class EmployeeConfiguration : IEntityTypeConfiguration<Employee>
{
    public void Configure(EntityTypeBuilder<Employee> builder)
    {
        builder.ToTable("employees");
        builder.HasKey(e => e.Id);
        builder.Property(e => e.FirstName).IsRequired().HasMaxLength(200);
        builder.Property(e => e.LastName).IsRequired().HasMaxLength(200);
        builder.Property(e => e.Status).IsRequired().HasMaxLength(50);
        builder.Property(e => e.Street).HasMaxLength(200);
        builder.Property(e => e.PostalCode).HasMaxLength(10);
        builder.Property(e => e.City).HasMaxLength(100);
        builder.Property(e => e.Country).HasMaxLength(100);
        builder.Property(e => e.PhoneNumber).HasMaxLength(50);
        builder.Property(e => e.Email).HasMaxLength(200);
        builder.Property(e => e.EmergencyContactName).HasMaxLength(200);
        builder.Property(e => e.EmergencyContactPhone).HasMaxLength(50);
        builder.Property(e => e.EmergencyContactRelation).HasMaxLength(100);
        builder.Property(e => e.EmploymentType).HasMaxLength(50);
        builder.Property(e => e.Qualification).HasMaxLength(500);

        // Soft-gelöschte Mitarbeiter sind für alle normalen Queries unsichtbar.
        builder.HasQueryFilter(e => !e.IsDeleted);
    }
}
