initial commit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
namespace Indotalent.Shared.Models;
|
||||
|
||||
public class ApiRequest
|
||||
{
|
||||
public int Skip { get; set; } = 1;
|
||||
public int Top { get; set; } = 5;
|
||||
public string? SearchTerm { get; set; }
|
||||
public string? SortBy { get; set; }
|
||||
public bool IsAscending { get; set; } = true;
|
||||
public bool IsPagedEnabled { get; set; } = true;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Indotalent.Shared.Models;
|
||||
|
||||
public class ApiResponse<T>
|
||||
{
|
||||
public bool IsSuccess { get; set; }
|
||||
public int StatusCode { get; set; }
|
||||
public string? Message { get; set; }
|
||||
public T? Value { get; set; }
|
||||
public PaginationMetadata? Pagination { get; set; }
|
||||
public List<string>? Errors { get; set; }
|
||||
public DateTime ServerTime { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public class PaginationMetadata
|
||||
{
|
||||
public int Count { get; set; }
|
||||
public int Top { get; set; }
|
||||
public int Skip { get; set; }
|
||||
public int TotalPages => (int)Math.Ceiling((double)Count / (Top == 0 ? 1 : Top));
|
||||
public bool HasPrevious => Skip > 0;
|
||||
public bool HasNext => (Skip + Top) < Count;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Indotalent.Shared.Models;
|
||||
|
||||
public class PagedList<T>
|
||||
{
|
||||
public PagedList()
|
||||
{
|
||||
Value = new List<T>();
|
||||
}
|
||||
|
||||
public List<T> Value { get; set; }
|
||||
public int Skip { get; set; }
|
||||
public int Top { get; set; }
|
||||
public int TotalPages { get; set; }
|
||||
public int Count { get; set; }
|
||||
|
||||
[JsonConstructor]
|
||||
public PagedList(List<T> value, int count, int skip, int top, int totalPages)
|
||||
{
|
||||
Value = value;
|
||||
Count = count;
|
||||
Skip = skip;
|
||||
Top = top;
|
||||
TotalPages = totalPages;
|
||||
}
|
||||
|
||||
public PagedList(List<T> value, int count, int skip, int top)
|
||||
{
|
||||
Value = value;
|
||||
Count = count;
|
||||
Skip = skip;
|
||||
Top = top;
|
||||
TotalPages = (int)Math.Ceiling(count / (double)top);
|
||||
}
|
||||
|
||||
public bool HasPrevious => Skip > 0;
|
||||
public bool HasNext => (Skip + Top) < Count;
|
||||
}
|
||||
Reference in New Issue
Block a user