Adding
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LCU.Library.Internal.DocumentIngestorModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.DocumentIngestorModels.Models.Pagination
|
||||
{
|
||||
public class Filter
|
||||
{
|
||||
/// <summary>
|
||||
/// Filter has default of all statuses to CreatedDate Descending for sorting.
|
||||
/// </summary>
|
||||
public Filter()
|
||||
{
|
||||
var listStatus = new List<StatusFilter>();
|
||||
foreach (var item in Enum.GetValues(typeof(ProcessStatusTypes)))
|
||||
{
|
||||
var statusFilters = new List<StatusFilter>
|
||||
{
|
||||
new() { IsEnabled = true, StatusType = (ProcessStatusTypes)item, IsUnknown = false },
|
||||
new() { IsEnabled = true, StatusType = (ProcessStatusTypes)item, IsUnknown = true }
|
||||
};
|
||||
listStatus.AddRange(statusFilters);
|
||||
}
|
||||
|
||||
var listSortableFields = new List<SortableField>();
|
||||
|
||||
SortableField sortField = new SortableField { Field = Constants.DocumentProcessingInfoSortableFields.CreatedDate, IsDescending = true };
|
||||
listSortableFields.Add(sortField);
|
||||
|
||||
this.StatusFilters = listStatus;
|
||||
this.SortableFields = listSortableFields;
|
||||
this.Page = 1;
|
||||
this.Limit = 10;
|
||||
}
|
||||
public string DocType { get; set; }
|
||||
public string DocBusinessName { get; set; }
|
||||
public Guid? IngestorRunInfoId { get; set; }
|
||||
public DateTime? CreatedDateStart { get; set; } = null;
|
||||
public DateTime? CreatedDateEnd { get; set; } = null;
|
||||
public List<StatusFilter> StatusFilters { get; set; }
|
||||
public IDictionary<string, string> CustomIndexFileFiltersEquals { get; set; } = null;
|
||||
public IDictionary<string, string> CustomIndexFileFiltersLikeOr { get; set; } = null;
|
||||
public List<SortableField> SortableFields { get; set; }
|
||||
public int Page { get; set; }
|
||||
[Range(1, 1000)]
|
||||
public int Limit { get; set; }
|
||||
public List<NotificationStatusTypes> NotificationStatusFilters { get; set; } = null;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LCU.Library.Internal.DocumentIngestorModels.Models.Pagination
|
||||
{
|
||||
public class PagedResponse<T> where T: class
|
||||
{
|
||||
public PagedResponse() { }
|
||||
public PagedResponse(PagedResult<T> pagedResult, Filter filter)
|
||||
{
|
||||
TotalItems = pagedResult.Total;
|
||||
Items = pagedResult.Items;
|
||||
TotalPages = pagedResult.Total == 0 ? 1 : (int)Math.Ceiling((decimal)pagedResult.Total / filter.Limit);
|
||||
CurrentPage = filter.Page > this.TotalPages ? this.TotalPages : filter.Page;
|
||||
|
||||
if (pagedResult.Total > (filter.Page * filter.Limit))
|
||||
{
|
||||
NextPage = filter.Page + 1;
|
||||
}
|
||||
if (filter.Page > 1)
|
||||
{
|
||||
PreviousPage = filter.Page - 1;
|
||||
}
|
||||
}
|
||||
public IEnumerable<T> Items { get; set; }
|
||||
public int NextPage { get; set; }
|
||||
public int PreviousPage { get; set; }
|
||||
public int TotalItems { get; set; }
|
||||
public int CurrentPage { get; set; }
|
||||
public int TotalPages { get; set; }
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LCU.Library.Internal.DocumentIngestorModels.Models.Pagination
|
||||
{
|
||||
public class PagedResult<T> where T: class
|
||||
{
|
||||
public IEnumerable<T> Items { get; set; }
|
||||
public int Total { get; set; }
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
namespace LCU.Library.Internal.DocumentIngestorModels.Models.Pagination
|
||||
{
|
||||
public class SortableField
|
||||
{
|
||||
public string Field { get; set; }
|
||||
public int Position { get; set; }
|
||||
public bool IsDescending { get; set; }
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
using LCU.Library.Internal.DocumentIngestorModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.DocumentIngestorModels.Models.Pagination
|
||||
{
|
||||
public class StatusFilter
|
||||
{
|
||||
public bool IsEnabled { get; set; }
|
||||
public bool IsUnknown { get; set; }
|
||||
public ProcessStatusTypes StatusType { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user