diff --git a/.gitignore b/.gitignore
index a87e29ab0..9999bab3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -450,3 +450,4 @@ appsettings.json
/API/Hangfire-log.db
cache/
/API/wwwroot/
+/API/cache/
\ No newline at end of file
diff --git a/API.Tests/API.Tests.csproj b/API.Tests/API.Tests.csproj
index b70443941..95af52570 100644
--- a/API.Tests/API.Tests.csproj
+++ b/API.Tests/API.Tests.csproj
@@ -25,7 +25,7 @@
-
+
diff --git a/API.Tests/ChapterSortComparerTest.cs b/API.Tests/ChapterSortComparerTest.cs
new file mode 100644
index 000000000..7ab909ec5
--- /dev/null
+++ b/API.Tests/ChapterSortComparerTest.cs
@@ -0,0 +1,19 @@
+using System.Linq;
+using API.Comparators;
+using Xunit;
+
+namespace API.Tests
+{
+ public class ChapterSortComparerTest
+ {
+ [Theory]
+ [InlineData(new[] {1, 2, 0}, new[] {1, 2, 0})]
+ [InlineData(new[] {3, 1, 2}, new[] {1, 2, 3})]
+ [InlineData(new[] {1, 0, 0}, new[] {1, 0, 0})]
+ public void ChapterSortTest(int[] input, int[] expected)
+ {
+ Assert.Equal(expected, input.OrderBy(f => f, new ChapterSortComparer()).ToArray());
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/API.Tests/Converters/CronConverterTests.cs b/API.Tests/Converters/CronConverterTests.cs
new file mode 100644
index 000000000..df1ca6294
--- /dev/null
+++ b/API.Tests/Converters/CronConverterTests.cs
@@ -0,0 +1,25 @@
+using API.Helpers.Converters;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace API.Tests.Converters
+{
+ public class CronConverterTests
+ {
+ private readonly ITestOutputHelper _testOutputHelper;
+
+ public CronConverterTests(ITestOutputHelper testOutputHelper)
+ {
+ _testOutputHelper = testOutputHelper;
+ }
+
+ [Theory]
+ [InlineData("daily", "0 0 * * *")]
+ [InlineData("disabled", "0 0 31 2 *")]
+ [InlineData("weekly", "0 0 * * 1")]
+ public void ConvertTest(string input, string expected)
+ {
+ Assert.Equal(expected, CronConverter.ConvertToCronNotation(input));
+ }
+ }
+}
\ No newline at end of file
diff --git a/API.Tests/ParserTest.cs b/API.Tests/ParserTest.cs
index 6cf1a64d1..34b7798a3 100644
--- a/API.Tests/ParserTest.cs
+++ b/API.Tests/ParserTest.cs
@@ -33,6 +33,9 @@ namespace API.Tests
[InlineData("Dorohedoro v01 (2010) (Digital) (LostNerevarine-Empire).cbz", "1")]
[InlineData("Dorohedoro v11 (2013) (Digital) (LostNerevarine-Empire).cbz", "11")]
[InlineData("Dorohedoro v12 (2013) (Digital) (LostNerevarine-Empire).cbz", "12")]
+ [InlineData("Yumekui_Merry_v01_c01[Bakayarou-Kuu].rar", "1")]
+ [InlineData("Yumekui-Merry_DKThias_Chapter11v2.zip", "0")]
+
public void ParseVolumeTest(string filename, string expected)
{
Assert.Equal(expected, ParseVolume(filename));
@@ -74,6 +77,8 @@ namespace API.Tests
[InlineData("Ichinensei_ni_Nacchattara_v01_ch01_[Taruby]_v1.1.zip", "Ichinensei ni Nacchattara")]
[InlineData("Chrno_Crusade_Dragon_Age_All_Stars[AS].zip", "")]
[InlineData("Ichiban_Ushiro_no_Daimaou_v04_ch34_[VISCANS].zip", "Ichiban Ushiro no Daimaou")]
+ [InlineData("Rent a Girlfriend v01.cbr", "Rent a Girlfriend")]
+ [InlineData("Yumekui_Merry_v01_c01[Bakayarou-Kuu].rar", "Yumekui Merry")]
//[InlineData("[Tempus Edax Rerum] Epigraph of the Closed Curve - Chapter 6.zip", "Epigraph of the Closed Curve")]
public void ParseSeriesTest(string filename, string expected)
{
@@ -102,6 +107,9 @@ namespace API.Tests
[InlineData("Mujaki no Rakuen Vol12 ch76", "76")]
[InlineData("Beelzebub_01_[Noodles].zip", "1")]
[InlineData("Yumekui-Merry_DKThias_Chapter21.zip", "21")]
+ [InlineData("Yumekui_Merry_v01_c01[Bakayarou-Kuu].rar", "1")]
+ [InlineData("Yumekui-Merry_DKThias_Chapter11v2.zip", "11")]
+ [InlineData("Beelzebub_53[KSH].zip", "53")]
//[InlineData("[Tempus Edax Rerum] Epigraph of the Closed Curve - Chapter 6.zip", "6")]
public void ParseChaptersTest(string filename, string expected)
{
@@ -158,6 +166,16 @@ namespace API.Tests
{
Assert.Equal(expected, ParseEdition(input));
}
+
+ [Theory]
+ [InlineData("12-14", 12)]
+ [InlineData("24", 24)]
+ [InlineData("18-04", 4)]
+ public void MinimumNumberFromRangeTest(string input, int expected)
+ {
+ Assert.Equal(expected, MinimumNumberFromRange(input));
+ }
+
[Fact]
public void ParseInfoTest()
diff --git a/API.Tests/Services/ArchiveServiceTests.cs b/API.Tests/Services/ArchiveServiceTests.cs
new file mode 100644
index 000000000..86f186b95
--- /dev/null
+++ b/API.Tests/Services/ArchiveServiceTests.cs
@@ -0,0 +1,73 @@
+using System.IO;
+using System.IO.Compression;
+using API.Interfaces;
+using API.Services;
+using Microsoft.Extensions.Logging;
+using NSubstitute;
+using Xunit;
+
+namespace API.Tests.Services
+{
+ public class ArchiveServiceTests
+ {
+ private readonly IArchiveService _archiveService;
+ private readonly ILogger _logger = Substitute.For>();
+
+ public ArchiveServiceTests()
+ {
+ _archiveService = new ArchiveService(_logger);
+ }
+
+ [Theory]
+ [InlineData("flat file.zip", false)]
+ [InlineData("file in folder in folder.zip", true)]
+ [InlineData("file in folder.zip", true)]
+ [InlineData("file in folder_alt.zip", true)]
+ public void ArchiveNeedsFlatteningTest(string archivePath, bool expected)
+ {
+ var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService/Archives");
+ var file = Path.Join(testDirectory, archivePath);
+ using ZipArchive archive = ZipFile.OpenRead(file);
+ Assert.Equal(expected, _archiveService.ArchiveNeedsFlattening(archive));
+ }
+
+ [Theory]
+ [InlineData("non existent file.zip", false)]
+ [InlineData("wrong extension.rar", false)]
+ [InlineData("empty.zip", false)]
+ [InlineData("flat file.zip", true)]
+ [InlineData("file in folder in folder.zip", true)]
+ [InlineData("file in folder.zip", true)]
+ [InlineData("file in folder_alt.zip", true)]
+ public void IsValidArchiveTest(string archivePath, bool expected)
+ {
+ var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService/Archives");
+ Assert.Equal(expected, _archiveService.IsValidArchive(Path.Join(testDirectory, archivePath)));
+ }
+
+ [Theory]
+ [InlineData("non existent file.zip", 0)]
+ [InlineData("wrong extension.rar", 0)]
+ [InlineData("empty.zip", 0)]
+ [InlineData("flat file.zip", 1)]
+ [InlineData("file in folder in folder.zip", 1)]
+ [InlineData("file in folder.zip", 1)]
+ [InlineData("file in folder_alt.zip", 1)]
+ public void GetNumberOfPagesFromArchiveTest(string archivePath, int expected)
+ {
+ var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService/Archives");
+ Assert.Equal(expected, _archiveService.GetNumberOfPagesFromArchive(Path.Join(testDirectory, archivePath)));
+ }
+
+ [Theory]
+ [InlineData("v10.cbz", "v10.expected.jpg")]
+ [InlineData("v10 - with folder.cbz", "v10 - with folder.expected.jpg")]
+ [InlineData("v10 - nested folder.cbz", "v10 - nested folder.expected.jpg")]
+ public void GetCoverImageTest(string inputFile, string expectedOutputFile)
+ {
+ var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService/CoverImages");
+ var expectedBytes = File.ReadAllBytes(Path.Join(testDirectory, expectedOutputFile));
+ Assert.Equal(expectedBytes, _archiveService.GetCoverImage(Path.Join(testDirectory, inputFile)));
+ }
+ }
+}
\ No newline at end of file
diff --git a/API.Tests/Services/CacheServiceTests.cs b/API.Tests/Services/CacheServiceTests.cs
new file mode 100644
index 000000000..80ee0438e
--- /dev/null
+++ b/API.Tests/Services/CacheServiceTests.cs
@@ -0,0 +1,98 @@
+using API.Interfaces;
+using API.Services;
+using Microsoft.Extensions.Logging;
+using NSubstitute;
+using Xunit;
+
+namespace API.Tests.Services
+{
+ public class CacheServiceTests
+ {
+ // private readonly CacheService _cacheService;
+ // private readonly ILogger _logger = Substitute.For>();
+ // private readonly IUnitOfWork _unitOfWork = Substitute.For();
+ // private readonly IArchiveService _archiveService = Substitute.For();
+ // private readonly IDirectoryService _directoryService = Substitute.For();
+
+ public CacheServiceTests()
+ {
+ //_cacheService = new CacheService(_logger, _unitOfWork, _archiveService, _directoryService);
+ }
+
+ //string GetCachedPagePath(Volume volume, int page)
+ [Fact]
+ //[InlineData("", 0, "")]
+ public void GetCachedPagePathTest_Should()
+ {
+ // TODO: Figure out how to test this
+ // string archivePath = "flat file.zip";
+ // int pageNum = 0;
+ // string expected = "cache/1/pexels-photo-6551949.jpg";
+ //
+ // var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService/Archives");
+ // var file = Path.Join(testDirectory, archivePath);
+ // var volume = new Volume
+ // {
+ // Id = 1,
+ // Files = new List()
+ // {
+ // new()
+ // {
+ // Id = 1,
+ // Chapter = 0,
+ // FilePath = archivePath,
+ // Format = MangaFormat.Archive,
+ // NumberOfPages = 1,
+ // }
+ // },
+ // Name = "1",
+ // Number = 1
+ // };
+ //
+ // var cacheService = Substitute.ForPartsOf();
+ // cacheService.Configure().CacheDirectoryIsAccessible().Returns(true);
+ // cacheService.Configure().GetVolumeCachePath(1, volume.Files.ElementAt(0)).Returns("cache/1/");
+ // _directoryService.Configure().GetFiles("cache/1/").Returns(new string[] {"pexels-photo-6551949.jpg"});
+ // Assert.Equal(expected, _cacheService.GetCachedPagePath(volume, pageNum));
+ Assert.True(true);
+ }
+
+ [Fact]
+ public void GetOrderedChaptersTest()
+ {
+ // var files = new List()
+ // {
+ // new()
+ // {
+ // Number = "1"
+ // },
+ // new()
+ // {
+ // Chapter = 2
+ // },
+ // new()
+ // {
+ // Chapter = 0
+ // },
+ // };
+ // var expected = new List()
+ // {
+ // new()
+ // {
+ // Chapter = 1
+ // },
+ // new()
+ // {
+ // Chapter = 2
+ // },
+ // new()
+ // {
+ // Chapter = 0
+ // },
+ // };
+ // Assert.NotStrictEqual(expected, _cacheService.GetOrderedChapters(files));
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/API.Tests/Services/ImageProviderTest.cs b/API.Tests/Services/ImageProviderTest.cs
deleted file mode 100644
index 5636d39a4..000000000
--- a/API.Tests/Services/ImageProviderTest.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.IO;
-using Xunit;
-
-namespace API.Tests.Services
-{
- public class ImageProviderTest
- {
- // [Theory]
- // [InlineData("v10.cbz", "v10.expected.jpg")]
- // [InlineData("v10 - with folder.cbz", "v10 - with folder.expected.jpg")]
- // [InlineData("v10 - nested folder.cbz", "v10 - nested folder.expected.jpg")]
- // public void GetCoverImageTest(string inputFile, string expectedOutputFile)
- // {
- // var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ImageProvider");
- // var expectedBytes = File.ReadAllBytes(Path.Join(testDirectory, expectedOutputFile));
- // // TODO: Implement this with ScannerService
- // //Assert.Equal(expectedBytes, ImageProvider.GetCoverImage(Path.Join(testDirectory, inputFile)));
- // }
- }
-}
\ No newline at end of file
diff --git a/API.Tests/Services/ScannerServiceTests.cs b/API.Tests/Services/ScannerServiceTests.cs
deleted file mode 100644
index 79b487a36..000000000
--- a/API.Tests/Services/ScannerServiceTests.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using API.Interfaces;
-using API.Services;
-using Microsoft.Extensions.Logging;
-using NSubstitute;
-
-namespace API.Tests.Services
-{
- public class ScannerServiceTests
- {
- private readonly ScannerService _scannerService;
- private readonly ILogger _logger = Substitute.For>();
- private readonly IUnitOfWork _unitOfWork = Substitute.For();
- public ScannerServiceTests()
- {
- _scannerService = new ScannerService(_unitOfWork, _logger);
- }
-
- // TODO: Start adding tests for how scanner works so we can ensure fallbacks, etc work
- }
-}
\ No newline at end of file
diff --git a/API.Tests/Services/StringLogicalComparerTest.cs b/API.Tests/Services/StringLogicalComparerTest.cs
index 25c5d3b2f..3ffa0f8a6 100644
--- a/API.Tests/Services/StringLogicalComparerTest.cs
+++ b/API.Tests/Services/StringLogicalComparerTest.cs
@@ -11,7 +11,6 @@ namespace API.Tests.Services
new[] {"x1.jpg", "x10.jpg", "x3.jpg", "x4.jpg", "x11.jpg"},
new[] {"x1.jpg", "x3.jpg", "x4.jpg", "x10.jpg", "x11.jpg"}
)]
-
public void TestLogicalComparer(string[] input, string[] expected)
{
NumericComparer nc = new NumericComparer();
diff --git a/API.Tests/Services/Test Data/ArchiveService/Archives/LICENSE.md b/API.Tests/Services/Test Data/ArchiveService/Archives/LICENSE.md
new file mode 100644
index 000000000..580f5f351
--- /dev/null
+++ b/API.Tests/Services/Test Data/ArchiveService/Archives/LICENSE.md
@@ -0,0 +1,2 @@
+Files in this test are all royalty free and can be found here:
+https://www.pexels.com/photo/snow-wood-light-art-6551949/
\ No newline at end of file
diff --git a/API.Tests/Services/Test Data/ArchiveService/Archives/empty.zip b/API.Tests/Services/Test Data/ArchiveService/Archives/empty.zip
new file mode 100644
index 000000000..15cb0ecb3
Binary files /dev/null and b/API.Tests/Services/Test Data/ArchiveService/Archives/empty.zip differ
diff --git a/API.Tests/Services/Test Data/ArchiveService/Archives/file in folder in folder.zip b/API.Tests/Services/Test Data/ArchiveService/Archives/file in folder in folder.zip
new file mode 100644
index 000000000..7598e0fa3
Binary files /dev/null and b/API.Tests/Services/Test Data/ArchiveService/Archives/file in folder in folder.zip differ
diff --git a/API.Tests/Services/Test Data/ArchiveService/Archives/file in folder.zip b/API.Tests/Services/Test Data/ArchiveService/Archives/file in folder.zip
new file mode 100644
index 000000000..b13a312b8
Binary files /dev/null and b/API.Tests/Services/Test Data/ArchiveService/Archives/file in folder.zip differ
diff --git a/API.Tests/Services/Test Data/ArchiveService/Archives/file in folder_alt.zip b/API.Tests/Services/Test Data/ArchiveService/Archives/file in folder_alt.zip
new file mode 100644
index 000000000..6607659b8
Binary files /dev/null and b/API.Tests/Services/Test Data/ArchiveService/Archives/file in folder_alt.zip differ
diff --git a/API.Tests/Services/Test Data/ArchiveService/Archives/flat file.zip b/API.Tests/Services/Test Data/ArchiveService/Archives/flat file.zip
new file mode 100644
index 000000000..344d49d64
Binary files /dev/null and b/API.Tests/Services/Test Data/ArchiveService/Archives/flat file.zip differ
diff --git a/API.Tests/Services/Test Data/ImageProvider/thumbnail.expected.jpg b/API.Tests/Services/Test Data/ArchiveService/CoverImages/thumbnail.expected.jpg
similarity index 100%
rename from API.Tests/Services/Test Data/ImageProvider/thumbnail.expected.jpg
rename to API.Tests/Services/Test Data/ArchiveService/CoverImages/thumbnail.expected.jpg
diff --git a/API.Tests/Services/Test Data/ImageProvider/thumbnail.jpg b/API.Tests/Services/Test Data/ArchiveService/CoverImages/thumbnail.jpg
similarity index 100%
rename from API.Tests/Services/Test Data/ImageProvider/thumbnail.jpg
rename to API.Tests/Services/Test Data/ArchiveService/CoverImages/thumbnail.jpg
diff --git a/API.Tests/Services/Test Data/ImageProvider/v10 - nested folder.cbz b/API.Tests/Services/Test Data/ArchiveService/CoverImages/v10 - nested folder.cbz
similarity index 100%
rename from API.Tests/Services/Test Data/ImageProvider/v10 - nested folder.cbz
rename to API.Tests/Services/Test Data/ArchiveService/CoverImages/v10 - nested folder.cbz
diff --git a/API.Tests/Services/Test Data/ImageProvider/v10 - nested folder.expected.jpg b/API.Tests/Services/Test Data/ArchiveService/CoverImages/v10 - nested folder.expected.jpg
similarity index 100%
rename from API.Tests/Services/Test Data/ImageProvider/v10 - nested folder.expected.jpg
rename to API.Tests/Services/Test Data/ArchiveService/CoverImages/v10 - nested folder.expected.jpg
diff --git a/API.Tests/Services/Test Data/ImageProvider/v10 - with folder.cbz b/API.Tests/Services/Test Data/ArchiveService/CoverImages/v10 - with folder.cbz
similarity index 100%
rename from API.Tests/Services/Test Data/ImageProvider/v10 - with folder.cbz
rename to API.Tests/Services/Test Data/ArchiveService/CoverImages/v10 - with folder.cbz
diff --git a/API.Tests/Services/Test Data/ImageProvider/v10 - with folder.expected.jpg b/API.Tests/Services/Test Data/ArchiveService/CoverImages/v10 - with folder.expected.jpg
similarity index 100%
rename from API.Tests/Services/Test Data/ImageProvider/v10 - with folder.expected.jpg
rename to API.Tests/Services/Test Data/ArchiveService/CoverImages/v10 - with folder.expected.jpg
diff --git a/API.Tests/Services/Test Data/ImageProvider/v10.cbz b/API.Tests/Services/Test Data/ArchiveService/CoverImages/v10.cbz
similarity index 100%
rename from API.Tests/Services/Test Data/ImageProvider/v10.cbz
rename to API.Tests/Services/Test Data/ArchiveService/CoverImages/v10.cbz
diff --git a/API.Tests/Services/Test Data/ImageProvider/v10.expected.jpg b/API.Tests/Services/Test Data/ArchiveService/CoverImages/v10.expected.jpg
similarity index 100%
rename from API.Tests/Services/Test Data/ImageProvider/v10.expected.jpg
rename to API.Tests/Services/Test Data/ArchiveService/CoverImages/v10.expected.jpg
diff --git a/API/Comparators/ChapterSortComparer.cs b/API/Comparators/ChapterSortComparer.cs
new file mode 100644
index 000000000..725622bec
--- /dev/null
+++ b/API/Comparators/ChapterSortComparer.cs
@@ -0,0 +1,18 @@
+using System.Collections.Generic;
+
+namespace API.Comparators
+{
+ public class ChapterSortComparer : IComparer
+ {
+ public int Compare(int x, int y)
+ {
+ if (x == 0 && y == 0) return 0;
+ // if x is 0, it comes second
+ if (x == 0) return 1;
+ // if y is 0, it comes second
+ if (y == 0) return -1;
+
+ return x.CompareTo(y);
+ }
+ }
+}
\ No newline at end of file
diff --git a/API/Comparators/StringLogicalComparer.cs b/API/Comparators/StringLogicalComparer.cs
index f6a8c1249..fe930c45c 100644
--- a/API/Comparators/StringLogicalComparer.cs
+++ b/API/Comparators/StringLogicalComparer.cs
@@ -20,16 +20,16 @@ namespace API.Comparators
if (string.IsNullOrEmpty(s2)) return -1;
//WE style, special case
- bool sp1 = Char.IsLetterOrDigit(s1, 0);
- bool sp2 = Char.IsLetterOrDigit(s2, 0);
+ var sp1 = Char.IsLetterOrDigit(s1, 0);
+ var sp2 = Char.IsLetterOrDigit(s2, 0);
if(sp1 && !sp2) return 1;
if(!sp1 && sp2) return -1;
int i1 = 0, i2 = 0; //current index
while(true)
{
- bool c1 = Char.IsDigit(s1, i1);
- bool c2 = Char.IsDigit(s2, i2);
+ var c1 = Char.IsDigit(s1, i1);
+ var c2 = Char.IsDigit(s2, i2);
int r; // temp result
if(!c1 && !c2)
{
diff --git a/API/Controllers/AdminController.cs b/API/Controllers/AdminController.cs
index 4aba6b7bd..3002947a2 100644
--- a/API/Controllers/AdminController.cs
+++ b/API/Controllers/AdminController.cs
@@ -20,9 +20,5 @@ namespace API.Controllers
var users = await _userManager.GetUsersInRoleAsync("Admin");
return users.Count > 0;
}
-
-
-
-
}
}
\ No newline at end of file
diff --git a/API/Controllers/FallbackController.cs b/API/Controllers/FallbackController.cs
index 74ff82999..36b173745 100644
--- a/API/Controllers/FallbackController.cs
+++ b/API/Controllers/FallbackController.cs
@@ -1,5 +1,4 @@
using System.IO;
-using API.Services;
using Microsoft.AspNetCore.Mvc;
namespace API.Controllers
diff --git a/API/Controllers/LibraryController.cs b/API/Controllers/LibraryController.cs
index ed193a4d0..3ecd6bf8a 100644
--- a/API/Controllers/LibraryController.cs
+++ b/API/Controllers/LibraryController.cs
@@ -145,7 +145,7 @@ namespace API.Controllers
[HttpPost("scan")]
public ActionResult Scan(int libraryId)
{
- _taskScheduler.ScanLibrary(libraryId, false);
+ _taskScheduler.ScanLibrary(libraryId);
return Ok();
}
@@ -177,13 +177,13 @@ namespace API.Controllers
var username = User.GetUsername();
_logger.LogInformation($"Library {libraryId} is being deleted by {username}.");
var series = await _unitOfWork.SeriesRepository.GetSeriesForLibraryIdAsync(libraryId);
- var volumes = (await _unitOfWork.SeriesRepository.GetVolumesForSeriesAsync(series.Select(x => x.Id).ToArray()))
- .Select(x => x.Id).ToArray();
+ var chapterIds =
+ await _unitOfWork.SeriesRepository.GetChapterIdsForSeriesAsync(series.Select(x => x.Id).ToArray());
var result = await _unitOfWork.LibraryRepository.DeleteLibrary(libraryId);
- if (result && volumes.Any())
+ if (result && chapterIds.Any())
{
- _taskScheduler.CleanupVolumes(volumes);
+ _taskScheduler.CleanupChapters(chapterIds);
}
return Ok(result);
diff --git a/API/Controllers/ReaderController.cs b/API/Controllers/ReaderController.cs
index d2fed05f7..7c535aa57 100644
--- a/API/Controllers/ReaderController.cs
+++ b/API/Controllers/ReaderController.cs
@@ -28,24 +28,28 @@ namespace API.Controllers
}
[HttpGet("image")]
- public async Task> GetImage(int volumeId, int page)
+ public async Task> GetImage(int chapterId, int page)
{
// Temp let's iterate the directory each call to get next image
- var volume = await _cacheService.Ensure(volumeId);
+ var chapter = await _cacheService.Ensure(chapterId);
- var path = _cacheService.GetCachedPagePath(volume, page);
+ if (chapter == null) return BadRequest("There was an issue finding image file for reading.");
+
+ var (path, mangaFile) = await _cacheService.GetCachedPagePath(chapter, page);
+ if (string.IsNullOrEmpty(path)) return BadRequest($"No such image for page {page}");
var file = await _directoryService.ReadImageAsync(path);
file.Page = page;
+ file.MangaFileName = mangaFile.FilePath;
return Ok(file);
}
[HttpGet("get-bookmark")]
- public async Task> GetBookmark(int volumeId)
+ public async Task> GetBookmark(int chapterId)
{
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
if (user.Progresses == null) return Ok(0);
- var progress = user.Progresses.SingleOrDefault(x => x.AppUserId == user.Id && x.VolumeId == volumeId);
+ var progress = user.Progresses.SingleOrDefault(x => x.AppUserId == user.Id && x.ChapterId == chapterId);
if (progress != null) return Ok(progress.PagesRead);
@@ -56,10 +60,12 @@ namespace API.Controllers
public async Task Bookmark(BookmarkDto bookmarkDto)
{
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
- _logger.LogInformation($"Saving {user.UserName} progress for {bookmarkDto.VolumeId} to page {bookmarkDto.PageNum}");
+ _logger.LogInformation($"Saving {user.UserName} progress for Chapter {bookmarkDto.ChapterId} to page {bookmarkDto.PageNum}");
+
+ // TODO: Don't let user bookmark past total pages.
user.Progresses ??= new List();
- var userProgress = user.Progresses.SingleOrDefault(x => x.VolumeId == bookmarkDto.VolumeId && x.AppUserId == user.Id);
+ var userProgress = user.Progresses.SingleOrDefault(x => x.ChapterId == bookmarkDto.ChapterId && x.AppUserId == user.Id);
if (userProgress == null)
{
@@ -69,13 +75,14 @@ namespace API.Controllers
PagesRead = bookmarkDto.PageNum,
VolumeId = bookmarkDto.VolumeId,
SeriesId = bookmarkDto.SeriesId,
+ ChapterId = bookmarkDto.ChapterId
});
}
else
{
userProgress.PagesRead = bookmarkDto.PageNum;
userProgress.SeriesId = bookmarkDto.SeriesId;
-
+ userProgress.VolumeId = bookmarkDto.VolumeId;
}
_unitOfWork.UserRepository.Update(user);
@@ -84,8 +91,7 @@ namespace API.Controllers
{
return Ok();
}
-
-
+
return BadRequest("Could not save progress");
}
}
diff --git a/API/Controllers/SeriesController.cs b/API/Controllers/SeriesController.cs
index fcd945c7c..78a16f015 100644
--- a/API/Controllers/SeriesController.cs
+++ b/API/Controllers/SeriesController.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using System.Linq;
using System.Threading.Tasks;
using API.DTOs;
using API.Entities;
@@ -36,17 +35,22 @@ namespace API.Controllers
public async Task> DeleteSeries(int seriesId)
{
var username = User.GetUsername();
- var volumes = (await _unitOfWork.SeriesRepository.GetVolumesForSeriesAsync(new []{seriesId})).Select(x => x.Id).ToArray();
+ var chapterIds = (await _unitOfWork.SeriesRepository.GetChapterIdsForSeriesAsync(new []{seriesId}));
_logger.LogInformation($"Series {seriesId} is being deleted by {username}.");
var result = await _unitOfWork.SeriesRepository.DeleteSeriesAsync(seriesId);
if (result)
{
- _taskScheduler.CleanupVolumes(volumes);
+ _taskScheduler.CleanupChapters(chapterIds);
}
return Ok(result);
}
+ ///
+ /// Returns All volumes for a series with progress information and Chapters
+ ///
+ ///
+ ///
[HttpGet("volumes")]
public async Task>> GetVolumes(int seriesId)
{
@@ -61,6 +65,12 @@ namespace API.Controllers
return Ok(await _unitOfWork.SeriesRepository.GetVolumeDtoAsync(volumeId, user.Id));
}
+ [HttpGet("chapter")]
+ public async Task> GetChapter(int chapterId)
+ {
+ return Ok(await _unitOfWork.VolumeRepository.GetChapterDtoAsync(chapterId));
+ }
+
[Authorize(Policy = "RequireAdminRole")]
[HttpPost("scan")]
public ActionResult Scan(int libraryId, int seriesId)
diff --git a/API/Controllers/SettingsController.cs b/API/Controllers/SettingsController.cs
index 910b10f89..eecece06c 100644
--- a/API/Controllers/SettingsController.cs
+++ b/API/Controllers/SettingsController.cs
@@ -1,17 +1,13 @@
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
+using System.IO;
using System.Threading.Tasks;
-using API.Data;
using API.DTOs;
using API.Entities;
using API.Extensions;
+using API.Helpers.Converters;
using API.Interfaces;
-using API.Services;
-using AutoMapper;
-using AutoMapper.QueryableExtensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace API.Controllers
@@ -19,32 +15,27 @@ namespace API.Controllers
[Authorize]
public class SettingsController : BaseApiController
{
- private readonly DataContext _dataContext;
private readonly ILogger _logger;
- private readonly IMapper _mapper;
- private readonly ITaskScheduler _taskScheduler;
+ private readonly IUnitOfWork _unitOfWork;
- public SettingsController(DataContext dataContext, ILogger logger, IMapper mapper, ITaskScheduler taskScheduler)
+ public SettingsController(ILogger logger, IUnitOfWork unitOfWork)
{
- _dataContext = dataContext;
_logger = logger;
- _mapper = mapper;
- _taskScheduler = taskScheduler;
+ _unitOfWork = unitOfWork;
}
[HttpGet("")]
public async Task> GetSettings()
{
- var settings = await _dataContext.ServerSetting.Select(x => x).ToListAsync();
- return _mapper.Map(settings);
+ return Ok(await _unitOfWork.SettingsRepository.GetSettingsDtoAsync());
}
-
+
[Authorize(Policy = "RequireAdminRole")]
[HttpPost("")]
- public async Task UpdateSettings(ServerSettingDto updateSettingsDto)
+ public async Task> UpdateSettings(ServerSettingDto updateSettingsDto)
{
_logger.LogInformation($"{User.GetUsername()} is updating Server Settings");
-
+
if (updateSettingsDto.CacheDirectory.Equals(string.Empty))
{
return BadRequest("Cache Directory cannot be empty");
@@ -54,13 +45,39 @@ namespace API.Controllers
{
return BadRequest("Directory does not exist or is not accessible.");
}
- // TODO: Figure out how to handle a change. This means that on clean, we need to clean up old cache
- // directory and new one, but what if someone is reading?
- // I can just clean both always, /cache/ is an owned folder, so users shouldn't use it.
-
-
- //_dataContext.ServerSetting.Update
- return BadRequest("Not Implemented");
+
+ // We do not allow CacheDirectory changes, so we will ignore.
+ var currentSettings = await _unitOfWork.SettingsRepository.GetSettingsAsync();
+
+ foreach (var setting in currentSettings)
+ {
+ if (setting.Key == ServerSettingKey.TaskBackup && updateSettingsDto.TaskBackup != setting.Value)
+ {
+ setting.Value = updateSettingsDto.TaskBackup;
+ _unitOfWork.SettingsRepository.Update(setting);
+ }
+
+ if (setting.Key == ServerSettingKey.TaskScan && updateSettingsDto.TaskScan != setting.Value)
+ {
+ setting.Value = updateSettingsDto.TaskScan;
+ _unitOfWork.SettingsRepository.Update(setting);
+ }
+ }
+
+ if (_unitOfWork.HasChanges() && await _unitOfWork.Complete())
+ {
+ _logger.LogInformation("Server Settings updated.");
+ return Ok(updateSettingsDto);
+ }
+
+ return BadRequest("There was a critical issue. Please try again.");
+ }
+
+ [Authorize(Policy = "RequireAdminRole")]
+ [HttpGet("task-frequencies")]
+ public ActionResult> GetTaskFrequencies()
+ {
+ return Ok(CronConverter.Options);
}
}
}
\ No newline at end of file
diff --git a/API/DTOs/ChapterDto.cs b/API/DTOs/ChapterDto.cs
new file mode 100644
index 000000000..ee58e6c18
--- /dev/null
+++ b/API/DTOs/ChapterDto.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+
+namespace API.DTOs
+{
+ public class ChapterDto
+ {
+ public int Id { get; set; }
+ ///
+ /// Range of chapters. Chapter 2-4 -> "2-4". Chapter 2 -> "2".
+ ///
+ public string Range { get; set; }
+ ///
+ /// Smallest number of the Range.
+ ///
+ public string Number { get; set; }
+ public byte[] CoverImage { get; set; }
+ ///
+ /// Total number of pages in all MangaFiles
+ ///
+ public int Pages { get; set; }
+ ///
+ /// The files that represent this Chapter
+ ///
+ public ICollection Files { get; set; }
+ ///
+ /// Calculated at API time. Number of pages read for this Chapter for logged in user.
+ ///
+ public int PagesRead { get; set; }
+ public int VolumeId { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/API/DTOs/ImageDto.cs b/API/DTOs/ImageDto.cs
index 473f2c110..18ffe7178 100644
--- a/API/DTOs/ImageDto.cs
+++ b/API/DTOs/ImageDto.cs
@@ -9,5 +9,7 @@
public int Height { get; init; }
public string Format { get; init; }
public byte[] Content { get; init; }
+ public int Chapter { get; set; }
+ public string MangaFileName { get; set; }
}
}
\ No newline at end of file
diff --git a/API/DTOs/MangaFileDto.cs b/API/DTOs/MangaFileDto.cs
new file mode 100644
index 000000000..8cf706ea8
--- /dev/null
+++ b/API/DTOs/MangaFileDto.cs
@@ -0,0 +1,12 @@
+using API.Entities;
+
+namespace API.DTOs
+{
+ public class MangaFileDto
+ {
+ public string FilePath { get; set; }
+ public int NumberOfPages { get; set; }
+ public MangaFormat Format { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/API/DTOs/ServerSettingDTO.cs b/API/DTOs/ServerSettingDTO.cs
index 455859305..e16d16506 100644
--- a/API/DTOs/ServerSettingDTO.cs
+++ b/API/DTOs/ServerSettingDTO.cs
@@ -3,7 +3,8 @@
public class ServerSettingDto
{
public string CacheDirectory { get; set; }
- // public string Kind { get; init; }
- // public string Value { get; init; }
+ public string TaskScan { get; set; }
+ public string LoggingLevel { get; set; }
+ public string TaskBackup { get; set; }
}
}
\ No newline at end of file
diff --git a/API/DTOs/VolumeDto.cs b/API/DTOs/VolumeDto.cs
index a57465857..39872c05a 100644
--- a/API/DTOs/VolumeDto.cs
+++ b/API/DTOs/VolumeDto.cs
@@ -1,4 +1,6 @@
+using System.Collections.Generic;
+
namespace API.DTOs
{
public class VolumeDto
@@ -9,5 +11,6 @@ namespace API.DTOs
public byte[] CoverImage { get; set; }
public int Pages { get; set; }
public int PagesRead { get; set; }
+ public ICollection Chapters { get; set; }
}
}
\ No newline at end of file
diff --git a/API/Data/BookmarkDto.cs b/API/Data/BookmarkDto.cs
index ea6654165..de7f1b6a7 100644
--- a/API/Data/BookmarkDto.cs
+++ b/API/Data/BookmarkDto.cs
@@ -3,6 +3,7 @@
public class BookmarkDto
{
public int VolumeId { get; init; }
+ public int ChapterId { get; init; }
public int PageNum { get; init; }
public int SeriesId { get; init; }
}
diff --git a/API/Data/DataContext.cs b/API/Data/DataContext.cs
index f89340f82..6aea9a959 100644
--- a/API/Data/DataContext.cs
+++ b/API/Data/DataContext.cs
@@ -20,8 +20,11 @@ namespace API.Data
}
public DbSet Library { get; set; }
public DbSet Series { get; set; }
+
+ public DbSet Chapter { get; set; }
public DbSet Volume { get; set; }
public DbSet AppUser { get; set; }
+ public DbSet MangaFile { get; set; }
public DbSet AppUserProgresses { get; set; }
public DbSet AppUserRating { get; set; }
public DbSet ServerSetting { get; set; }
@@ -30,10 +33,6 @@ namespace API.Data
{
base.OnModelCreating(builder);
- // builder.Entity()
- // .HasAlternateKey(s => s.Key)
- // .HasName("AlternateKey_Key");
-
builder.Entity()
.HasMany(ur => ur.UserRoles)
.WithOne(u => u.User)
diff --git a/API/Data/Migrations/20210128143348_SeriesVolumeChapterChange.Designer.cs b/API/Data/Migrations/20210128143348_SeriesVolumeChapterChange.Designer.cs
new file mode 100644
index 000000000..17cb4b81d
--- /dev/null
+++ b/API/Data/Migrations/20210128143348_SeriesVolumeChapterChange.Designer.cs
@@ -0,0 +1,688 @@
+//
+using System;
+using API.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace API.Data.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20210128143348_SeriesVolumeChapterChange")]
+ partial class SeriesVolumeChapterChange
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.1");
+
+ modelBuilder.Entity("API.Entities.AppRole", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex");
+
+ b.ToTable("AspNetRoles");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AccessFailedCount")
+ .HasColumnType("INTEGER");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("Email")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("EmailConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastActive")
+ .HasColumnType("TEXT");
+
+ b.Property("LockoutEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("LockoutEnd")
+ .HasColumnType("TEXT");
+
+ b.Property("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("PasswordHash")
+ .HasColumnType("TEXT");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("TEXT");
+
+ b.Property("PhoneNumberConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("TEXT");
+
+ b.Property("TwoFactorEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex");
+
+ b.ToTable("AspNetUsers");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserProgress", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property("PagesRead")
+ .HasColumnType("INTEGER");
+
+ b.Property("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("AppUserProgresses");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRating", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Rating")
+ .HasColumnType("INTEGER");
+
+ b.Property("Review")
+ .HasColumnType("TEXT");
+
+ b.Property("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("AppUserRating");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRole", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetUserRoles");
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CoverImage")
+ .HasColumnType("BLOB");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property("Number")
+ .HasColumnType("TEXT");
+
+ b.Property("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property("Range")
+ .HasColumnType("TEXT");
+
+ b.Property("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("VolumeId");
+
+ b.ToTable("Chapter");
+ });
+
+ modelBuilder.Entity("API.Entities.FolderPath", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("LastScanned")
+ .HasColumnType("TEXT");
+
+ b.Property("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Path")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("FolderPath");
+ });
+
+ modelBuilder.Entity("API.Entities.Library", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("Type")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.MangaFile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Chapter")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property("FilePath")
+ .HasColumnType("TEXT");
+
+ b.Property("Format")
+ .HasColumnType("INTEGER");
+
+ b.Property("NumberOfPages")
+ .HasColumnType("INTEGER");
+
+ b.Property("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ChapterId");
+
+ b.HasIndex("VolumeId");
+
+ b.ToTable("MangaFile");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CoverImage")
+ .HasColumnType("BLOB");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("OriginalName")
+ .HasColumnType("TEXT");
+
+ b.Property("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property("SortName")
+ .HasColumnType("TEXT");
+
+ b.Property("Summary")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.ServerSetting", b =>
+ {
+ b.Property("Key")
+ .HasColumnType("TEXT");
+
+ b.Property("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Key");
+
+ b.ToTable("ServerSetting");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CoverImage")
+ .HasColumnType("BLOB");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("IsSpecial")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("Number")
+ .HasColumnType("INTEGER");
+
+ b.Property("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("Volume");
+ });
+
+ modelBuilder.Entity("AppUserLibrary", b =>
+ {
+ b.Property("AppUsersId")
+ .HasColumnType("INTEGER");
+
+ b.Property("LibrariesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("AppUsersId", "LibrariesId");
+
+ b.HasIndex("LibrariesId");
+
+ b.ToTable("AppUserLibrary");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property("ProviderKey")
+ .HasColumnType("TEXT");
+
+ b.Property("ProviderDisplayName")
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserLogins");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("AspNetUserTokens");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserProgress", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Progresses")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRating", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Ratings")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRole", b =>
+ {
+ b.HasOne("API.Entities.AppRole", "Role")
+ .WithMany("UserRoles")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.AppUser", "User")
+ .WithMany("UserRoles")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.HasOne("API.Entities.Volume", "Volume")
+ .WithMany("Chapters")
+ .HasForeignKey("VolumeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Volume");
+ });
+
+ modelBuilder.Entity("API.Entities.FolderPath", b =>
+ {
+ b.HasOne("API.Entities.Library", "Library")
+ .WithMany("Folders")
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.MangaFile", b =>
+ {
+ b.HasOne("API.Entities.Chapter", null)
+ .WithMany("Files")
+ .HasForeignKey("ChapterId");
+
+ b.HasOne("API.Entities.Volume", "Volume")
+ .WithMany()
+ .HasForeignKey("VolumeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Volume");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.HasOne("API.Entities.Library", "Library")
+ .WithMany("Series")
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.HasOne("API.Entities.Series", "Series")
+ .WithMany("Volumes")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("AppUserLibrary", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("AppUsersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Library", null)
+ .WithMany()
+ .HasForeignKey("LibrariesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.HasOne("API.Entities.AppRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("API.Entities.AppRole", b =>
+ {
+ b.Navigation("UserRoles");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUser", b =>
+ {
+ b.Navigation("Progresses");
+
+ b.Navigation("Ratings");
+
+ b.Navigation("UserRoles");
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.Navigation("Files");
+ });
+
+ modelBuilder.Entity("API.Entities.Library", b =>
+ {
+ b.Navigation("Folders");
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.Navigation("Volumes");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.Navigation("Chapters");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/API/Data/Migrations/20210128143348_SeriesVolumeChapterChange.cs b/API/Data/Migrations/20210128143348_SeriesVolumeChapterChange.cs
new file mode 100644
index 000000000..ae6e6b6d1
--- /dev/null
+++ b/API/Data/Migrations/20210128143348_SeriesVolumeChapterChange.cs
@@ -0,0 +1,111 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace API.Data.Migrations
+{
+ public partial class SeriesVolumeChapterChange : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "IsSpecial",
+ table: "Volume",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: false);
+
+ migrationBuilder.AddColumn(
+ name: "ChapterId",
+ table: "MangaFile",
+ type: "INTEGER",
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "LastScanned",
+ table: "FolderPath",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn(
+ name: "ChapterId",
+ table: "AppUserProgresses",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: 0);
+
+ migrationBuilder.CreateTable(
+ name: "Chapter",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Range = table.Column(type: "TEXT", nullable: true),
+ Number = table.Column(type: "TEXT", nullable: true),
+ Created = table.Column(type: "TEXT", nullable: false),
+ LastModified = table.Column(type: "TEXT", nullable: false),
+ CoverImage = table.Column(type: "BLOB", nullable: true),
+ Pages = table.Column(type: "INTEGER", nullable: false),
+ VolumeId = table.Column(type: "INTEGER", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Chapter", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Chapter_Volume_VolumeId",
+ column: x => x.VolumeId,
+ principalTable: "Volume",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_MangaFile_ChapterId",
+ table: "MangaFile",
+ column: "ChapterId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Chapter_VolumeId",
+ table: "Chapter",
+ column: "VolumeId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_MangaFile_Chapter_ChapterId",
+ table: "MangaFile",
+ column: "ChapterId",
+ principalTable: "Chapter",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_MangaFile_Chapter_ChapterId",
+ table: "MangaFile");
+
+ migrationBuilder.DropTable(
+ name: "Chapter");
+
+ migrationBuilder.DropIndex(
+ name: "IX_MangaFile_ChapterId",
+ table: "MangaFile");
+
+ migrationBuilder.DropColumn(
+ name: "IsSpecial",
+ table: "Volume");
+
+ migrationBuilder.DropColumn(
+ name: "ChapterId",
+ table: "MangaFile");
+
+ migrationBuilder.DropColumn(
+ name: "LastScanned",
+ table: "FolderPath");
+
+ migrationBuilder.DropColumn(
+ name: "ChapterId",
+ table: "AppUserProgresses");
+ }
+ }
+}
diff --git a/API/Data/Migrations/20210128201832_MangaFileChapterRelationship.Designer.cs b/API/Data/Migrations/20210128201832_MangaFileChapterRelationship.Designer.cs
new file mode 100644
index 000000000..5d0cfa7b5
--- /dev/null
+++ b/API/Data/Migrations/20210128201832_MangaFileChapterRelationship.Designer.cs
@@ -0,0 +1,676 @@
+//
+using System;
+using API.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace API.Data.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20210128201832_MangaFileChapterRelationship")]
+ partial class MangaFileChapterRelationship
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.1");
+
+ modelBuilder.Entity("API.Entities.AppRole", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex");
+
+ b.ToTable("AspNetRoles");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AccessFailedCount")
+ .HasColumnType("INTEGER");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("Email")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("EmailConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastActive")
+ .HasColumnType("TEXT");
+
+ b.Property("LockoutEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("LockoutEnd")
+ .HasColumnType("TEXT");
+
+ b.Property("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("PasswordHash")
+ .HasColumnType("TEXT");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("TEXT");
+
+ b.Property("PhoneNumberConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("TEXT");
+
+ b.Property("TwoFactorEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex");
+
+ b.ToTable("AspNetUsers");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserProgress", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property("PagesRead")
+ .HasColumnType("INTEGER");
+
+ b.Property("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("AppUserProgresses");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRating", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Rating")
+ .HasColumnType("INTEGER");
+
+ b.Property("Review")
+ .HasColumnType("TEXT");
+
+ b.Property("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("AppUserRating");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRole", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetUserRoles");
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CoverImage")
+ .HasColumnType("BLOB");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property("Number")
+ .HasColumnType("TEXT");
+
+ b.Property("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property("Range")
+ .HasColumnType("TEXT");
+
+ b.Property("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("VolumeId");
+
+ b.ToTable("Chapter");
+ });
+
+ modelBuilder.Entity("API.Entities.FolderPath", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("LastScanned")
+ .HasColumnType("TEXT");
+
+ b.Property("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Path")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("FolderPath");
+ });
+
+ modelBuilder.Entity("API.Entities.Library", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("Type")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.MangaFile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property("FilePath")
+ .HasColumnType("TEXT");
+
+ b.Property("Format")
+ .HasColumnType("INTEGER");
+
+ b.Property("NumberOfPages")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ChapterId");
+
+ b.ToTable("MangaFile");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CoverImage")
+ .HasColumnType("BLOB");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("OriginalName")
+ .HasColumnType("TEXT");
+
+ b.Property("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property("SortName")
+ .HasColumnType("TEXT");
+
+ b.Property("Summary")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.ServerSetting", b =>
+ {
+ b.Property("Key")
+ .HasColumnType("TEXT");
+
+ b.Property("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Key");
+
+ b.ToTable("ServerSetting");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CoverImage")
+ .HasColumnType("BLOB");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("IsSpecial")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("Number")
+ .HasColumnType("INTEGER");
+
+ b.Property("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("Volume");
+ });
+
+ modelBuilder.Entity("AppUserLibrary", b =>
+ {
+ b.Property("AppUsersId")
+ .HasColumnType("INTEGER");
+
+ b.Property("LibrariesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("AppUsersId", "LibrariesId");
+
+ b.HasIndex("LibrariesId");
+
+ b.ToTable("AppUserLibrary");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property