Add email domain entities and .NET Framework support

Introduced `EmailAccount`, `EmailAttachment`, and `ReceivedEmail`
entities with database mappings using data annotations. These
entities represent email account configurations, attachments,
and received emails, respectively.

Added conditional compilation to ensure compatibility between
.NET and .NET Framework. Updated `DigitalData.MessagingService.Domain.csproj`
to include `System.ComponentModel.DataAnnotations` for `net462`.

Defined relationships between entities, including navigation
properties and foreign key constraints.
This commit is contained in:
2026-08-12 16:08:29 +02:00
parent b2857c558f
commit be28a61d9c
4 changed files with 246 additions and 0 deletions

View File

@@ -1,52 +1,75 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DigitalData.MessagingService.Domain.Entities;
/// <summary>
/// DTO for a single email account configuration.
/// </summary>
[Table("EMAIL_ACCOUNT")]
public class EmailAccount
{
/// <summary>
/// Logical name to identify this account (e.g. "default", "support").
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("ID", TypeName = "int")]
public int Id { get; set; }
[Required]
[MaxLength(256)]
[Column("USERNAME", TypeName = "nvarchar(256)")]
#if NET
public required string Username { get; set; }
#else
public string Username { get; set; } = null!;
#endif
[Required]
[MaxLength(512)]
[Column("PASSWORD", TypeName = "nvarchar(512)")]
#if NET
public required string Password { get; set; }
#else
public string Password { get; set; } = null!;
#endif
[Required]
[MaxLength(256)]
[Column("SMTP_SERVER", TypeName = "nvarchar(256)")]
#if NET
public required string SmtpServer { get; set; }
#else
public string SmtpServer { get; set; } = null!;
#endif
[Column("SMTP_PORT", TypeName = "int")]
public int SmtpPort { get; set; }
[Column("SMTP_USE_SSL", TypeName = "bit")]
public bool SmtpUseSsl { get; set; }
[Column("USE_OAUTH2", TypeName = "bit")]
public bool UseOAuth2 { get; set; }
/// <summary>
/// IMAP server hostname (e.g. "imap.example.com").
/// Leave empty when this account is send-only.
/// </summary>
[MaxLength(256)]
[Column("IMAP_SERVER", TypeName = "nvarchar(256)")]
public string? ImapServer { get; set; }
/// <summary>
/// IMAP server port (993 for SSL, 143 for plain/STARTTLS).
/// </summary>
[Column("IMAP_PORT", TypeName = "int")]
public int ImapPort { get; set; } = 993;
/// <summary>
/// Use SSL/TLS when connecting to the IMAP server.
/// </summary>
[Column("IMAP_USE_SSL", TypeName = "bit")]
public bool ImapUseSsl { get; set; } = true;
}