diff --git a/IRaCIS.Core.Application/Service/Common/DTO/EmailLogViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/EmailLogViewModel.cs index 247908408..724746d11 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/EmailLogViewModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/EmailLogViewModel.cs @@ -14,6 +14,17 @@ namespace IRaCIS.Core.Application.ViewModel; public class GetReSendEmailInDto : PageInput { public Guid Id { get; set; } + + + public DateTime? EmailStartDate { get; set; } + + public DateTime? EmailEndDate { get; set; } + + public EmailState? EmailStateEnum { get; set; } + + public string ToRecipientName { get; set; } = string.Empty; + + public string CcRecipientName { get; set; } = string.Empty; } public class EmailLogView : EmailLogAddOrEdit { diff --git a/IRaCIS.Core.Application/Service/Common/EmailLogService.cs b/IRaCIS.Core.Application/Service/Common/EmailLogService.cs index 6af33cf19..177658f23 100644 --- a/IRaCIS.Core.Application/Service/Common/EmailLogService.cs +++ b/IRaCIS.Core.Application/Service/Common/EmailLogService.cs @@ -93,6 +93,11 @@ public class EmailLogService(IRepository _emailLogRepository, var emailLogQueryable = _emailLogRepository .Where(x => reSendMessagelist.Contains(x.MessageId)) + .WhereIf(inDto.EmailStartDate.HasValue, x => x.EmailDate >= inDto.EmailStartDate.Value) + .WhereIf(inDto.EmailEndDate.HasValue, x => x.EmailDate <= inDto.EmailEndDate.Value) + .WhereIf(inDto.EmailStateEnum.HasValue, x => x.EmailStateEnum == inDto.EmailStateEnum.Value) + .WhereIf(inDto.CcRecipientName.IsNotNullOrEmpty(), x => x.EmailRecipientLogList.Any(x => x.RecipientTypeEnum == RecipientType.Cc && x.RecipientName.Contains(inDto.CcRecipientName))) + .WhereIf(inDto.ToRecipientName.IsNotNullOrEmpty(), x => x.EmailRecipientLogList.Any(x => x.RecipientTypeEnum == RecipientType.To && x.RecipientName.Contains(inDto.ToRecipientName))) .ProjectTo(_mapper.ConfigurationProvider); var defalutSortArray = new string[] { nameof(EmailLogView.EmailDate) + " desc" };