diff --git a/API/Controllers/DTOs/Author.cs b/API/Controllers/DTOs/Author.cs
index 0e2403b..a7b0999 100644
--- a/API/Controllers/DTOs/Author.cs
+++ b/API/Controllers/DTOs/Author.cs
@@ -6,7 +6,7 @@ namespace API.Controllers.DTOs;
///
/// The DTO
///
-public record Author(string Key, string Name) : Identifiable(Key)
+public sealed record Author(string Key, string Name) : Identifiable(Key)
{
///
/// Name of the Author.
diff --git a/API/Controllers/DTOs/Chapter.cs b/API/Controllers/DTOs/Chapter.cs
index aab2860..f7ec832 100644
--- a/API/Controllers/DTOs/Chapter.cs
+++ b/API/Controllers/DTOs/Chapter.cs
@@ -6,7 +6,7 @@ namespace API.Controllers.DTOs;
///
/// DTO
///
-public record Chapter(string Key, string MangaId, int? Volume, string ChapterNumber, string? Title, IEnumerable MangaConnectorIds, bool Downloaded) : Identifiable(Key)
+public sealed record Chapter(string Key, string MangaId, int? Volume, string ChapterNumber, string? Title, IEnumerable MangaConnectorIds, bool Downloaded) : Identifiable(Key)
{
///
/// Identifier of the Manga this Chapter belongs to
diff --git a/API/Controllers/DTOs/FileLibrary.cs b/API/Controllers/DTOs/FileLibrary.cs
new file mode 100644
index 0000000..a8d9960
--- /dev/null
+++ b/API/Controllers/DTOs/FileLibrary.cs
@@ -0,0 +1,14 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace API.Controllers.DTOs;
+
+public sealed record FileLibrary(string Key, string BasePath, string LibraryName) : Identifiable(Key)
+{
+ [StringLength(256)]
+ [Required]
+ public string BasePath { get; internal set; } = BasePath;
+
+ [StringLength(512)]
+ [Required]
+ public string LibraryName { get; internal set; } = LibraryName;
+}
\ No newline at end of file
diff --git a/API/Controllers/DTOs/Manga.cs b/API/Controllers/DTOs/Manga.cs
index 76bd34e..f37e40e 100644
--- a/API/Controllers/DTOs/Manga.cs
+++ b/API/Controllers/DTOs/Manga.cs
@@ -7,7 +7,7 @@ namespace API.Controllers.DTOs;
///
/// DTO
///
-public record Manga(string Key, string Name, string Description, MangaReleaseStatus ReleaseStatus, IEnumerable MangaConnectorIds, float IgnoreChaptersBefore, uint? Year, string? OriginalLanguage, IEnumerable ChapterIds, IEnumerable Authors, IEnumerable Tags, IEnumerable Links, IEnumerable AltTitles, string? FileLibraryId)
+public sealed record Manga(string Key, string Name, string Description, MangaReleaseStatus ReleaseStatus, IEnumerable MangaConnectorIds, float IgnoreChaptersBefore, uint? Year, string? OriginalLanguage, IEnumerable ChapterIds, IEnumerable Authors, IEnumerable Tags, IEnumerable Links, IEnumerable AltTitles, string? FileLibraryId)
: MinimalManga(Key, Name, Description, ReleaseStatus, MangaConnectorIds)
{
///
diff --git a/API/Controllers/FileLibraryController.cs b/API/Controllers/FileLibraryController.cs
index fba8910..69e9ee0 100644
--- a/API/Controllers/FileLibraryController.cs
+++ b/API/Controllers/FileLibraryController.cs
@@ -4,6 +4,8 @@ using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using static Microsoft.AspNetCore.Http.StatusCodes;
+using FileLibrary = API.Controllers.DTOs.FileLibrary;
+
// ReSharper disable InconsistentNaming
namespace API.Controllers;
@@ -14,18 +16,21 @@ namespace API.Controllers;
public class FileLibraryController(MangaContext context) : Controller
{
///
- /// Returns all
+ /// Returns all
///
///
/// Error during Database Operation
[HttpGet]
- [ProducesResponseType(Status200OK, "application/json")]
+ [ProducesResponseType>(Status200OK, "application/json")]
[ProducesResponseType(Status500InternalServerError)]
public async Task>, InternalServerError>> GetFileLibraries ()
{
if (await context.FileLibraries.ToListAsync(HttpContext.RequestAborted) is not { } result)
return TypedResults.InternalServerError();
- return TypedResults.Ok(result);
+
+ List fileLibraries = result.Select(f => new FileLibrary(f.Key, f.BasePath, f.LibraryName)).ToList();
+
+ return TypedResults.Ok(fileLibraries);
}
///
@@ -42,7 +47,7 @@ public class FileLibraryController(MangaContext context) : Controller
if(await context.FileLibraries.FirstOrDefaultAsync(l => l.Key == FileLibraryId, HttpContext.RequestAborted) is not { } library)
return TypedResults.NotFound(nameof(FileLibraryId));
- return TypedResults.Ok(library);
+ return TypedResults.Ok(new FileLibrary(library.Key, library.BasePath, library.LibraryName));
}
///
@@ -98,15 +103,16 @@ public class FileLibraryController(MangaContext context) : Controller
///
/// Creates new
///
- /// New to add
+ /// New to add
/// Key of new Library
/// Error during Database Operation
[HttpPut]
[ProducesResponseType(Status201Created, "text/plain")]
[ProducesResponseType(Status500InternalServerError, "text/plain")]
- public async Task, InternalServerError>> CreateNewLibrary ([FromBody]FileLibrary library)
+ public async Task, InternalServerError>> CreateNewLibrary ([FromBody]CreateLibraryRecord requestData)
{
//TODO Parameter check
+ Schema.MangaContext.FileLibrary library = new Schema.MangaContext.FileLibrary(requestData.BasePath, requestData.LibraryName);
context.FileLibraries.Add(library);
if(await context.Sync(HttpContext.RequestAborted) is { success: false } result)
@@ -114,6 +120,7 @@ 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