33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using System.Linq;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using LCU.Library.Internal.DocumentIngestorModels.Entities;
|
|
using LCU.Library.Internal.DocumentIngestorModels.Models.Pagination;
|
|
using System;
|
|
|
|
namespace LCU.Api.Internal.DocumentIngestorLib.Extensions.Queryables
|
|
{
|
|
public static class DocumentProcessingInfoCreatedDateQueryable
|
|
{
|
|
public static IQueryable<DocumentProcessingInfo> FilterByCreatedDate(this IQueryable<DocumentProcessingInfo> queryable, Filter filter)
|
|
{
|
|
if (filter?.CreatedDateStart == null && filter?.CreatedDateEnd == null)
|
|
{
|
|
return queryable;
|
|
}
|
|
|
|
if (filter?.CreatedDateStart == null)
|
|
{
|
|
filter.CreatedDateStart = DateTime.MinValue;
|
|
}
|
|
|
|
if (filter?.CreatedDateEnd == null || filter?.CreatedDateEnd == DateTime.MinValue)
|
|
{
|
|
filter.CreatedDateEnd = DateTime.MaxValue;
|
|
}
|
|
|
|
return queryable.Where(DocumentProcessingInfo => DocumentProcessingInfo.CreatedDate >= filter.CreatedDateStart &&
|
|
DocumentProcessingInfo.CreatedDate <= filter.CreatedDateEnd);
|
|
}
|
|
}
|
|
}
|