v1.0 release

This commit is contained in:
Cameron
2024-08-27 03:29:38 -05:00
parent a4403ce17b
commit ef7c3f9dbd
38 changed files with 1172 additions and 73 deletions

7
Models/AuthorResponse.cs Normal file
View File

@@ -0,0 +1,7 @@
namespace ComiServ.Models
{
public record class AuthorResponse(string Name, int WorkCount)
{
}
}

View File

@@ -0,0 +1,8 @@
namespace ComiServ.Models
{
//handle is taken from URL
public record class ComicDeleteRequest
(
bool DeleteIfFileExists
);
}

View File

@@ -0,0 +1,23 @@
using ComiServ.Entities;
namespace ComiServ.Models
{
public class ComicDuplicateList
{
public long Hash { get; set; }
public int Count { get; set; }
public List<ComicData> Comics { get; set; }
public ComicDuplicateList(long hash, IEnumerable<Comic> comics)
{
Hash = hash;
Comics = comics.Select(c => new ComicData(c)).ToList();
Count = Comics.Count;
}
public ComicDuplicateList(long hash, IEnumerable<ComicData> comics)
{
Hash = hash;
Comics = comics.ToList();
Count = Comics.Count;
}
}
}

View File

@@ -1,6 +1,6 @@
namespace ComiServ.Models
{
public class ComicMetadataUpdate
public class ComicMetadataUpdateRequest
{
public string? Title { get; set; }
public string? Description { get; set; }

View File

@@ -0,0 +1,6 @@
namespace ComiServ.Models
{
public record class LibraryResponse(int ComicCount, int UniqueFiles)
{
}
}

View File

@@ -19,7 +19,7 @@
{
throw new ArgumentOutOfRangeException(nameof(page), page, "must be greater than or equal to 0");
}
Items = iter.Take(max + 1).ToList();
Items = iter.Skip(max * page).Take(max + 1).ToList();
if (Items.Count > max)
{
Last = false;

View File

@@ -1,18 +1,29 @@
namespace ComiServ.Models
{
public class RequestError
{
using System.Collections;
namespace ComiServ.Models
{
public class RequestError : IEnumerable<string>
{
public static RequestError InvalidHandle => new("Invalid handle");
public static RequestError ComicNotFound => new("Comic not found");
public static RequestError CoverNotFound => new("Cover not found");
public static RequestError PageNotFound => new("Page not found");
public static RequestError FileNotFound => new("File not found");
public static RequestError ThumbnailNotFound => new("Thumbnail not found");
public static RequestError NotAuthenticated => new("Not authenticated");
public static RequestError NoAccess => new("User does not have access to this resource");
public static RequestError UserNotFound => new("User not found");
public static RequestError ComicFileExists => new("Comic file exists so comic not deleted");
public static RequestError UserSpecificEndpoint => new("Endpoint is user-specific, requires login");
public string[] Errors { get; }
public RequestError(string ErrorMessage)
{
Errors = [ErrorMessage];
}
public RequestError()
{
Errors = [];
}
public RequestError(IEnumerable<string> ErrorMessages)
{
Errors = ErrorMessages.ToArray();
@@ -27,8 +38,15 @@
}
public RequestError And(IEnumerable<string> other)
{
return new RequestError(Errors.Concat(other))
;
return new RequestError(Errors.Concat(other));
}
public IEnumerator<string> GetEnumerator()
{
return ((IEnumerable<string>)Errors).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}

7
Models/TagResponse.cs Normal file
View File

@@ -0,0 +1,7 @@
namespace ComiServ.Models
{
public record class TagResponse(string Name, int WorkCount)
{
}
}

View File

@@ -19,11 +19,10 @@ namespace ComiServ.Models
if (Items.Count <= max)
{
Complete = true;
if (Items.Count > 0)
Items.RemoveAt(max);
}
else
{
Items.RemoveAt(max);
Complete = false;
}
Count = Items.Count;

View File

@@ -0,0 +1,12 @@
using ComiServ.Entities;
namespace ComiServ.Models
{
public class UserCreateRequest
{
public string Username { get; set; }
public UserTypeEnum UserType { get; set; }
//NOT HASHED do not persist this object
public string Password { get; set; }
}
}

View File

@@ -0,0 +1,4 @@
namespace ComiServ.Models
{
public record class UserDescription(string Username, string Usertype);
}

View File

@@ -0,0 +1,11 @@
using ComiServ.Entities;
namespace ComiServ.Models
{
public class UserModifyRequest
{
public string Username { get; set; }
public string? NewUsername { get; set; }
public UserTypeEnum? NewUserType { get; set; }
}
}