using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TIAM.Entities.Emails;

namespace TIAM.Database.ModelBuilders.Emails;

public static class EmailMessageEntityTypeBuilderExtensions
{
    public static void BuildEmailMessageToRecipientRelation(this EntityTypeBuilder<EmailMessage> modelBuilder, bool autoInclude = true)
    {
        modelBuilder
            .HasMany(x => x.Recipients)
            .WithOne(x => x.EmailMessage);

        modelBuilder.Navigation(e => e.Recipients).AutoInclude(autoInclude);
    }
}