refactor(application): Remove old DTOs and mapping profiles, consolidate into EmailMappingProfile
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Dtos.EmailAttachments;
|
||||
|
||||
/// <summary>
|
||||
/// DTO for creating EmailAttachment record.
|
||||
/// AutoMapper profile required: CreateEmailAttachmentDto -> EmailAttachment
|
||||
/// </summary>
|
||||
public record CreateEmailAttachmentDto(
|
||||
int EmailHistoryId,
|
||||
string OriginalFileName,
|
||||
string SavedFileName,
|
||||
string FilePath,
|
||||
long FileSize,
|
||||
string Extension,
|
||||
string ContentType,
|
||||
byte[] Content);
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Dtos.EmailAttachments;
|
||||
|
||||
/// <summary>
|
||||
/// DTO for EmailAttachment query results.
|
||||
/// </summary>
|
||||
public class EmailAttachmentDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string OriginalFileName { get; set; } = string.Empty;
|
||||
public string FilePath { get; set; } = string.Empty;
|
||||
public long FileSize { get; set; }
|
||||
public bool IsEmbeddedFile { get; set; }
|
||||
public string? Status { get; set; }
|
||||
public string? ValidationErrorMessage { get; set; }
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Dtos.EmailAttachments;
|
||||
|
||||
/// <summary>
|
||||
/// DTO for updating EmailAttachment status.
|
||||
/// AutoMapper profile required: UpdateEmailAttachmentStatusDto -> EmailAttachment
|
||||
/// </summary>
|
||||
public record UpdateEmailAttachmentStatusDto(
|
||||
string Status,
|
||||
int? ValidationErrorCode = null,
|
||||
string? ValidationErrorMessage = null);
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Dtos.EmailHistories;
|
||||
|
||||
/// <summary>
|
||||
/// DTO for creating EmailHistory record.
|
||||
/// AutoMapper profile required: CreateEmailHistoryDto -> EmailHistory
|
||||
/// </summary>
|
||||
public record CreateEmailHistoryDto(
|
||||
int ProfileId,
|
||||
string MessageIdHash,
|
||||
string OriginalMessageId,
|
||||
string SenderAddress,
|
||||
DateTime EmailDate,
|
||||
string Subject,
|
||||
string? EmailBodyText,
|
||||
string? EmailBodyHtml);
|
||||
@@ -1,21 +0,0 @@
|
||||
using DigitalData.EmailProfiler.Application.Common.Dtos.EmailAttachments;
|
||||
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Dtos.EmailHistories;
|
||||
|
||||
/// <summary>
|
||||
/// DTO for EmailHistory query results.
|
||||
/// </summary>
|
||||
public class EmailHistoryDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int? ProfileId { get; set; }
|
||||
public string? ProfileName { get; set; }
|
||||
public string? SenderAddress { get; set; }
|
||||
public string? Subject { get; set; }
|
||||
public DateTime? EmailDate { get; set; }
|
||||
public DateTime? ProcessedDate { get; set; }
|
||||
public string? Status { get; set; }
|
||||
public int? ErrorCodeValue { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public List<EmailAttachmentDto> Attachments { get; set; } = new();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Dtos.EmailHistories;
|
||||
|
||||
/// <summary>
|
||||
/// DTO for updating EmailHistory status.
|
||||
/// AutoMapper profile required: UpdateEmailHistoryStatusDto -> EmailHistory
|
||||
/// </summary>
|
||||
public record UpdateEmailHistoryStatusDto(
|
||||
string Status,
|
||||
DateTime? ProcessedDate = null,
|
||||
int? ErrorCodeValue = null,
|
||||
string? ErrorMessage = null);
|
||||
@@ -1,18 +0,0 @@
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// DTO for EmailProfile query results.
|
||||
/// </summary>
|
||||
public class EmailProfileDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ProfileName { get; set; } = string.Empty;
|
||||
public int EmailAccountId { get; set; }
|
||||
public string? EmailAccountName { get; set; }
|
||||
public int? ProcessId { get; set; }
|
||||
public string? ProcessName { get; set; }
|
||||
public int PollIntervalMinutes { get; set; }
|
||||
public DateTime? LastPollTime { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public string? Comment { get; set; }
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.EmailProfiler.Application.Common.Dtos;
|
||||
using DigitalData.EmailProfiler.Domain.Entities;
|
||||
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Mappings;
|
||||
|
||||
/// <summary>
|
||||
/// AutoMapper profile for EmailAccount entity mappings.
|
||||
/// </summary>
|
||||
public class EmailAccountMappingProfile : Profile
|
||||
{
|
||||
public EmailAccountMappingProfile()
|
||||
{
|
||||
// Entity -> DTO (for Queries)
|
||||
CreateMap<EmailAccount, EmailAccountDto>();
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.EmailProfiler.Application.Common.Dtos.EmailAttachments;
|
||||
using DigitalData.EmailProfiler.Domain.Entities;
|
||||
using DigitalData.EmailProfiler.Domain.Enums;
|
||||
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Mappings;
|
||||
|
||||
/// <summary>
|
||||
/// AutoMapper profile for EmailAttachment entity mappings.
|
||||
/// </summary>
|
||||
public class EmailAttachmentMappingProfile : Profile
|
||||
{
|
||||
public EmailAttachmentMappingProfile()
|
||||
{
|
||||
// DTO -> Entity (for Create)
|
||||
CreateMap<CreateEmailAttachmentDto, EmailAttachment>()
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore()) // Auto-generated
|
||||
.ForMember(dest => dest.Status, opt => opt.MapFrom(_ => AttachmentStatus.Pending.ToString()))
|
||||
.ForMember(dest => dest.AddedWhen, opt => opt.MapFrom(_ => DateTime.Now))
|
||||
.ForMember(dest => dest.IsEmbeddedFile, opt => opt.MapFrom(_ => false))
|
||||
.ForMember(dest => dest.ParentAttachmentId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.AttachmentPosition, opt => opt.MapFrom(_ => 0))
|
||||
.ForMember(dest => dest.ValidationErrorCode, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ValidationErrorMessage, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Comment, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailHistory, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ParentAttachment, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmbeddedFiles, opt => opt.Ignore());
|
||||
|
||||
// DTO -> Entity (for Update Status)
|
||||
CreateMap<UpdateEmailAttachmentStatusDto, EmailAttachment>()
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailHistoryId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.OriginalFileName, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.SavedFileName, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.FilePath, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.FileSize, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Extension, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.IsEmbeddedFile, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ParentAttachmentId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.AttachmentPosition, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Comment, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.AddedWhen, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailHistory, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ParentAttachment, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmbeddedFiles, opt => opt.Ignore());
|
||||
|
||||
// Entity -> DTO (for Queries)
|
||||
CreateMap<EmailAttachment, EmailAttachmentDto>();
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.EmailProfiler.Application.Common.Dtos.EmailHistories;
|
||||
using DigitalData.EmailProfiler.Domain.Entities;
|
||||
using DigitalData.EmailProfiler.Domain.Enums;
|
||||
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Mappings;
|
||||
|
||||
/// <summary>
|
||||
/// AutoMapper profile for EmailHistory entity mappings.
|
||||
/// </summary>
|
||||
public class EmailHistoryMappingProfile : Profile
|
||||
{
|
||||
public EmailHistoryMappingProfile()
|
||||
{
|
||||
// DTO -> Entity (for Create)
|
||||
CreateMap<CreateEmailHistoryDto, EmailHistory>()
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore()) // Auto-generated
|
||||
.ForMember(dest => dest.EmailMessageId, opt => opt.Ignore()) // Auto-generated
|
||||
.ForMember(dest => dest.Status, opt => opt.MapFrom(_ => EmailStatus.Processing.ToString()))
|
||||
.ForMember(dest => dest.AddedWhen, opt => opt.MapFrom(_ => DateTime.Now))
|
||||
.ForMember(dest => dest.ProcessedDate, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ErrorCodeValue, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ErrorMessage, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.WindreamDocumentId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Comment, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.WorkProcess, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ImapUid, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailSubstring1, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailSubstring2, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Profile, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Attachments, opt => opt.Ignore());
|
||||
|
||||
// DTO -> Entity (for Update Status)
|
||||
CreateMap<UpdateEmailHistoryStatusDto, EmailHistory>()
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ProfileId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.MessageIdHash, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.OriginalMessageId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.SenderAddress, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailDate, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Subject, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailBodyText, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailBodyHtml, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailMessageId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.AddedWhen, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.WindreamDocumentId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Comment, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.WorkProcess, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ImapUid, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailSubstring1, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailSubstring2, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Profile, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Attachments, opt => opt.Ignore());
|
||||
|
||||
// Entity -> DTO (for Queries)
|
||||
CreateMap<EmailHistory, EmailHistoryDto>()
|
||||
.ForMember(dest => dest.ProfileName, opt => opt.MapFrom(src => src.Profile != null ? src.Profile.ProfileName : null));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.EmailProfiler.Application.Common.Events;
|
||||
using DigitalData.EmailProfiler.Application.EmailSending.Commands;
|
||||
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Mappings;
|
||||
|
||||
/// <summary>
|
||||
/// AutoMapper profile for Emails
|
||||
/// </summary>
|
||||
public class EmailMappingProfile : Profile
|
||||
{
|
||||
public EmailMappingProfile()
|
||||
{
|
||||
// SendEmailCommand -> OutgoingEmailEvent
|
||||
CreateMap<SendEmailCommand, OutgoingEmailEvent>()
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(_ => Guid.NewGuid()))
|
||||
.ForMember(dest => dest.QueuedAt, opt => opt.MapFrom(_ => DateTime.Now));
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.EmailProfiler.Application.EmailSending.Commands;
|
||||
using DigitalData.EmailProfiler.Domain.Entities;
|
||||
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Mappings;
|
||||
|
||||
/// <summary>
|
||||
/// AutoMapper profile for EmailOutbox entity
|
||||
/// </summary>
|
||||
public class EmailOutboxMappingProfile : Profile
|
||||
{
|
||||
public EmailOutboxMappingProfile()
|
||||
{
|
||||
// SendEmailCommand -> EmailOutbox
|
||||
CreateMap<SendEmailCommand, EmailOutbox>()
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore()) // Auto-generated
|
||||
.ForMember(dest => dest.Sent, opt => opt.Ignore()) // Set by handler
|
||||
.ForMember(dest => dest.SentDate, opt => opt.Ignore()) // Set when sent
|
||||
.ForMember(dest => dest.RetryCount, opt => opt.Ignore()) // Set by handler
|
||||
.ForMember(dest => dest.AddedWhen, opt => opt.Ignore()) // Set by handler
|
||||
.ForMember(dest => dest.EmailAccount, opt => opt.Ignore()); // Navigation property
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.EmailProfiler.Application.Common.Dtos;
|
||||
using DigitalData.EmailProfiler.Domain.Entities;
|
||||
|
||||
namespace DigitalData.EmailProfiler.Application.Common.Mappings;
|
||||
|
||||
/// <summary>
|
||||
/// AutoMapper profile for EmailProfile entity mappings.
|
||||
/// </summary>
|
||||
public class EmailProfileMappingProfile : Profile
|
||||
{
|
||||
public EmailProfileMappingProfile()
|
||||
{
|
||||
// Entity -> DTO (for Queries)
|
||||
CreateMap<EmailProfile, EmailProfileDto>()
|
||||
.ForMember(dest => dest.EmailAccountName, opt => opt.MapFrom(src => src.EmailAccount != null ? src.EmailAccount.AccountName : null))
|
||||
.ForMember(dest => dest.ProcessName, opt => opt.MapFrom(src => src.EmailProcess != null ? src.EmailProcess.ProcessName : null))
|
||||
.ForMember(dest => dest.LastPollTime, opt => opt.MapFrom(src => src.LastPollTime));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user