diff --git a/API/Controllers/DTOs/FileLibrary.cs b/API/Controllers/DTOs/FileLibrary.cs index a8d9960..af83f07 100644 --- a/API/Controllers/DTOs/FileLibrary.cs +++ b/API/Controllers/DTOs/FileLibrary.cs @@ -1,14 +1,21 @@ +using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace API.Controllers.DTOs; public sealed record FileLibrary(string Key, string BasePath, string LibraryName) : Identifiable(Key) { - [StringLength(256)] + /// + /// The directory Path of the library + /// [Required] + [Description("The directory Path of the library")] public string BasePath { get; internal set; } = BasePath; - [StringLength(512)] + /// + /// The Name of the library + /// [Required] + [Description("The Name of the library")] public string LibraryName { get; internal set; } = LibraryName; } \ No newline at end of file diff --git a/API/Controllers/DTOs/LibraryConnector.cs b/API/Controllers/DTOs/LibraryConnector.cs index 9f5bf88..03c1c37 100644 --- a/API/Controllers/DTOs/LibraryConnector.cs +++ b/API/Controllers/DTOs/LibraryConnector.cs @@ -1,3 +1,4 @@ +using System.ComponentModel; using System.ComponentModel.DataAnnotations; using API.Schema.LibraryContext.LibraryConnectors; @@ -5,11 +6,18 @@ namespace API.Controllers.DTOs; public record LibraryConnector(string Key, string BaseUrl, LibraryType Type) : Identifiable(Key) { - [StringLength(256)] + /// + /// The Url of the Library instance + /// [Required] [Url] - public string BaseUrl {get; init;} = BaseUrl; + [Description("The Url of the Library instance")] + public string BaseUrl { get; init;} = BaseUrl; + /// + /// The + /// [Required] + [Description("The Library Type")] public LibraryType Type { get; init; } = Type; } \ No newline at end of file diff --git a/API/Controllers/FileLibraryController.cs b/API/Controllers/FileLibraryController.cs index 69e9ee0..deaca58 100644 --- a/API/Controllers/FileLibraryController.cs +++ b/API/Controllers/FileLibraryController.cs @@ -1,4 +1,5 @@ -using API.Schema.MangaContext; +using API.Controllers.Requests; +using API.Schema.MangaContext; using Asp.Versioning; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; @@ -120,7 +121,6 @@ public class FileLibraryController(MangaContext context) : Controller return TypedResults.Created(string.Empty, library.Key); } - public sealed record CreateLibraryRecord(string BasePath, string LibraryName); /// /// Deletes the .LibraryName with diff --git a/API/Controllers/LibraryConnectorController.cs b/API/Controllers/LibraryConnectorController.cs index ac4ff48..4c4e63d 100644 --- a/API/Controllers/LibraryConnectorController.cs +++ b/API/Controllers/LibraryConnectorController.cs @@ -1,4 +1,5 @@ -using API.Schema.LibraryContext; +using API.Controllers.Requests; +using API.Schema.LibraryContext; using API.Schema.LibraryContext.LibraryConnectors; using Asp.Versioning; using Microsoft.AspNetCore.Http.HttpResults; @@ -75,7 +76,6 @@ public class LibraryConnectorController(LibraryContext context) : Controller return TypedResults.InternalServerError(result.exceptionMessage); return TypedResults.Created(string.Empty, connector.Key); } - public sealed record CreateLibraryConnectorRecord(LibraryType LibraryType, string Url, string Username, string Password); /// /// Deletes with diff --git a/API/Controllers/MangaController.cs b/API/Controllers/MangaController.cs index 7c5d7ba..fa81b6d 100644 --- a/API/Controllers/MangaController.cs +++ b/API/Controllers/MangaController.cs @@ -1,5 +1,4 @@ -using System.Diagnostics.CodeAnalysis; -using API.Controllers.DTOs; +using API.Controllers.DTOs; using API.Schema.MangaContext; using API.Workers; using Asp.Versioning; diff --git a/API/Controllers/Requests/CreateLibraryConnectorRecord.cs b/API/Controllers/Requests/CreateLibraryConnectorRecord.cs new file mode 100644 index 0000000..14a5012 --- /dev/null +++ b/API/Controllers/Requests/CreateLibraryConnectorRecord.cs @@ -0,0 +1,37 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using API.Schema.LibraryContext.LibraryConnectors; + +namespace API.Controllers.Requests; + +public sealed record CreateLibraryConnectorRecord(LibraryType LibraryType, string Url, string Username, string Password) +{ + /// + /// The + /// + [Required] + [Description("The Library Type")] + public LibraryType LibraryType { get; init; } = LibraryType; + + /// + /// The Url of the Library instance + /// + [Required] + [Url] + [Description("The Url of the Library instance")] + public string Url { get; init; } = Url; + + /// + /// The Username to authenticate to the Library instance + /// + [Required] + [Description("The Username to authenticate to the Library instance")] + public string Username { get; init; } = Username; + + /// + /// The Password to authenticate to the Library instance + /// + [Required] + [Description("The Password to authenticate to the Library instance")] + public string Password { get; init; } = Password; +} \ No newline at end of file diff --git a/API/Controllers/Requests/CreateLibraryRecord.cs b/API/Controllers/Requests/CreateLibraryRecord.cs new file mode 100644 index 0000000..4ec9829 --- /dev/null +++ b/API/Controllers/Requests/CreateLibraryRecord.cs @@ -0,0 +1,21 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace API.Controllers.Requests; + +public sealed record CreateLibraryRecord(string BasePath, string LibraryName) +{ + /// + /// The directory Path of the library + /// + [Required] + [Description("The directory Path of the library")] + public string BasePath { get; init; } = BasePath; + + /// + /// The Name of the library + /// + [Required] + [Description("The Name of the library")] + public string LibraryName { get; init; } = LibraryName; +} \ No newline at end of file diff --git a/API/Schema/LibraryContext/LibraryConnectors/LibraryConnector.cs b/API/Schema/LibraryContext/LibraryConnectors/LibraryConnector.cs index 236e152..8a9b003 100644 --- a/API/Schema/LibraryContext/LibraryConnectors/LibraryConnector.cs +++ b/API/Schema/LibraryContext/LibraryConnectors/LibraryConnector.cs @@ -10,9 +10,9 @@ namespace API.Schema.LibraryContext.LibraryConnectors; public abstract class LibraryConnector : Identifiable { public LibraryType LibraryType { get; init; } - public string BaseUrl { get; init; } - public string Auth { get; init; } - protected ILog Log { get; init; } + [StringLength(256)] [Url] public string BaseUrl { get; init; } + [StringLength(256)] public string Auth { get; init; } + [NotMapped] protected ILog Log { get; init; } protected LibraryConnector(LibraryType libraryType, string baseUrl, string auth) : base() diff --git a/API/Schema/MangaContext/FileLibrary.cs b/API/Schema/MangaContext/FileLibrary.cs index 1cc61f4..2f245cf 100644 --- a/API/Schema/MangaContext/FileLibrary.cs +++ b/API/Schema/MangaContext/FileLibrary.cs @@ -7,13 +7,9 @@ namespace API.Schema.MangaContext; public class FileLibrary(string basePath, string libraryName) : Identifiable(TokenGen.CreateToken(typeof(FileLibrary), basePath)) { - [StringLength(256)] - [Required] - public string BasePath { get; internal set; } = basePath; + [StringLength(256)] public string BasePath { get; internal set; } = basePath; - [StringLength(512)] - [Required] - public string LibraryName { get; internal set; } = libraryName; + [StringLength(512)] public string LibraryName { get; internal set; } = libraryName; public override string ToString() => $"{base.ToString()} {LibraryName} - {BasePath}"; } \ No newline at end of file