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

32
Models/Truncated.cs Normal file
View File

@@ -0,0 +1,32 @@
using System.Reflection.PortableExecutable;
namespace ComiServ.Models
{
public class Truncated<T>
{
public int Max { get; }
public int Count { get; }
public bool Complete { get; }
public List<T> Items { get; }
public Truncated(int max, IEnumerable<T> items)
{
if (max <= 0)
{
throw new ArgumentOutOfRangeException(nameof(max), max, "must be greater than 0");
}
Max = max;
Items = items.Take(max+1).ToList();
if (Items.Count <= max)
{
Complete = true;
if (Items.Count > 0)
Items.RemoveAt(max);
}
else
{
Complete = false;
}
Count = Items.Count;
}
}
}