API mostly working, starting to work on webapp

This commit is contained in:
Cameron
2024-08-23 23:52:36 -05:00
commit a4403ce17b
26 changed files with 1725 additions and 0 deletions

35
Models/Paginated.cs Normal file
View File

@@ -0,0 +1,35 @@
namespace ComiServ.Models
{
public class Paginated<T>
{
public int Max { get; }
public int Page { get;}
public bool Last { get; }
public int Count { get; }
public List<T> Items { get; }
public Paginated(int max, int page, IEnumerable<T> iter)
{
Max = max;
Page = page;
if (max <= 0)
{
throw new ArgumentOutOfRangeException(nameof(max), max, "must be greater than 0");
}
if (page < 0)
{
throw new ArgumentOutOfRangeException(nameof(page), page, "must be greater than or equal to 0");
}
Items = iter.Take(max + 1).ToList();
if (Items.Count > max)
{
Last = false;
Items.RemoveAt(max);
}
else
{
Last = true;
}
Count = Items.Count;
}
}
}