public async Task <NotificationLogFilterDto> SearchNotificationLogs(NotificationLogFilterDto model) { var expression = GetSearchExpressionNotificationLog(model); (var query, int totalCount) = await AuditUnitOfWork.NotificationLogRepository.GetPagedByFiltersAsync( model.PageNumber, model.jtPageSize.Value, expression, a => a.OrderByDescending(d => d.TryDate)); model.Items = query.Select(notification => NotificationLogMapper.MapToDto(notification)).ToList(); model.TotalCount = totalCount; return(model); }
List <Expression <Func <NotificationLog, bool> > > GetSearchExpressionNotificationLog(NotificationLogFilterDto model) { List <Expression <Func <NotificationLog, bool> > > filterList = new List <Expression <Func <NotificationLog, bool> > >(); if (model.SendSucceeded != null) { filterList.Add(c => c.SendSucceeded == model.SendSucceeded); } if (model.FromTryDate != null) { filterList.Add(c => c.TryDate.Date >= model.FromTryDate); } if (model.ToTryDate != null) { filterList.Add(c => c.TryDate.Date <= model.ToTryDate); } return(filterList); }