diff --git a/Treestar.Shared/AccessLayers/ApiAccessLayer.cs b/Common/AccessLayers/ApiAccessLayer.cs similarity index 97% rename from Treestar.Shared/AccessLayers/ApiAccessLayer.cs rename to Common/AccessLayers/ApiAccessLayer.cs index caeb9ff..d5107fc 100644 --- a/Treestar.Shared/AccessLayers/ApiAccessLayer.cs +++ b/Common/AccessLayers/ApiAccessLayer.cs @@ -1,11 +1,11 @@ using System.Net.Mime; using System.Text; +using Common.Models; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Newtonsoft.Json; -using Treestar.Shared.Models; -namespace Treestar.Shared.AccessLayers; +namespace Common.AccessLayers; public abstract class ApiAccessLayer { @@ -18,7 +18,7 @@ public abstract class ApiAccessLayer _authenticationProvider = authenticationProvider; Logger = logger; var handler = new HttpClientHandler() - { + { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }; _httpClient = new HttpClient(handler); diff --git a/Treestar.Shared/AccessLayers/IAccessLayerAuthenticationProvider.cs b/Common/AccessLayers/IAccessLayerAuthenticationProvider.cs similarity index 73% rename from Treestar.Shared/AccessLayers/IAccessLayerAuthenticationProvider.cs rename to Common/AccessLayers/IAccessLayerAuthenticationProvider.cs index a9d98df..19429c4 100644 --- a/Treestar.Shared/AccessLayers/IAccessLayerAuthenticationProvider.cs +++ b/Common/AccessLayers/IAccessLayerAuthenticationProvider.cs @@ -1,4 +1,4 @@ -namespace Treestar.Shared.AccessLayers; +namespace Common.AccessLayers; public interface IAccessLayerAuthenticationProvider { diff --git a/Treestar.Shared/Authentication/JwtBearer/JWTAuthenticationExtension.cs b/Common/Authentication/JwtBearer/JWTAuthenticationExtension.cs similarity index 95% rename from Treestar.Shared/Authentication/JwtBearer/JWTAuthenticationExtension.cs rename to Common/Authentication/JwtBearer/JWTAuthenticationExtension.cs index c1e00c9..9b878ee 100644 --- a/Treestar.Shared/Authentication/JwtBearer/JWTAuthenticationExtension.cs +++ b/Common/Authentication/JwtBearer/JWTAuthenticationExtension.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Tokens; -namespace Treestar.Shared.Authentication.JwtBearer; +namespace Common.Authentication.JwtBearer; public static class JWTAuthenticationExtension { diff --git a/Treestar.Shared/Authentication/JwtBearer/JwtBearerAuthenticationOptions.cs b/Common/Authentication/JwtBearer/JwtBearerAuthenticationOptions.cs similarity index 80% rename from Treestar.Shared/Authentication/JwtBearer/JwtBearerAuthenticationOptions.cs rename to Common/Authentication/JwtBearer/JwtBearerAuthenticationOptions.cs index 928c74a..c9ff601 100644 --- a/Treestar.Shared/Authentication/JwtBearer/JwtBearerAuthenticationOptions.cs +++ b/Common/Authentication/JwtBearer/JwtBearerAuthenticationOptions.cs @@ -1,4 +1,4 @@ -namespace Treestar.Shared.Authentication.JwtBearer; +namespace Common.Authentication.JwtBearer; public class JwtBearerAuthenticationOptions { diff --git a/Treestar.Shared/Authentication/OIDC/AuthenticationExtension.cs b/Common/Authentication/OIDC/AuthenticationExtension.cs similarity index 97% rename from Treestar.Shared/Authentication/OIDC/AuthenticationExtension.cs rename to Common/Authentication/OIDC/AuthenticationExtension.cs index 66cf5da..f79f9a6 100644 --- a/Treestar.Shared/Authentication/OIDC/AuthenticationExtension.cs +++ b/Common/Authentication/OIDC/AuthenticationExtension.cs @@ -7,7 +7,7 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using WebNovelPortal.Authentication; -namespace Treestar.Shared.Authentication.OIDC; +namespace Common.Authentication.OIDC; public static class AuthenticationExtension { diff --git a/Treestar.Shared/Authentication/OIDC/OpenIdConnectAuthenticationOptions.cs b/Common/Authentication/OIDC/OpenIdConnectAuthenticationOptions.cs similarity index 100% rename from Treestar.Shared/Authentication/OIDC/OpenIdConnectAuthenticationOptions.cs rename to Common/Authentication/OIDC/OpenIdConnectAuthenticationOptions.cs diff --git a/Treestar.Shared/Treestar.Shared.csproj b/Common/Common.csproj similarity index 100% rename from Treestar.Shared/Treestar.Shared.csproj rename to Common/Common.csproj diff --git a/Treestar.Shared/Models/DBDomain/Author.cs b/Common/Models/DBDomain/Author.cs similarity index 94% rename from Treestar.Shared/Models/DBDomain/Author.cs rename to Common/Models/DBDomain/Author.cs index 307a32c..d292ca7 100644 --- a/Treestar.Shared/Models/DBDomain/Author.cs +++ b/Common/Models/DBDomain/Author.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using Newtonsoft.Json; -namespace Treestar.Shared.Models.DBDomain +namespace Common.Models.DBDomain { public class Author : BaseEntity { diff --git a/Treestar.Shared/Models/DBDomain/BaseEntity.cs b/Common/Models/DBDomain/BaseEntity.cs similarity index 78% rename from Treestar.Shared/Models/DBDomain/BaseEntity.cs rename to Common/Models/DBDomain/BaseEntity.cs index 27837f4..ec15e2c 100644 --- a/Treestar.Shared/Models/DBDomain/BaseEntity.cs +++ b/Common/Models/DBDomain/BaseEntity.cs @@ -1,4 +1,4 @@ -namespace Treestar.Shared.Models.DBDomain +namespace Common.Models.DBDomain { public abstract class BaseEntity { diff --git a/Treestar.Shared/Models/DBDomain/Chapter.cs b/Common/Models/DBDomain/Chapter.cs similarity index 96% rename from Treestar.Shared/Models/DBDomain/Chapter.cs rename to Common/Models/DBDomain/Chapter.cs index 0b70d24..b27123b 100644 --- a/Treestar.Shared/Models/DBDomain/Chapter.cs +++ b/Common/Models/DBDomain/Chapter.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace Treestar.Shared.Models.DBDomain +namespace Common.Models.DBDomain { public class Chapter : BaseEntity { diff --git a/Treestar.Shared/Models/DBDomain/Novel.cs b/Common/Models/DBDomain/Novel.cs similarity index 93% rename from Treestar.Shared/Models/DBDomain/Novel.cs rename to Common/Models/DBDomain/Novel.cs index 0f9a1dc..9518091 100644 --- a/Treestar.Shared/Models/DBDomain/Novel.cs +++ b/Common/Models/DBDomain/Novel.cs @@ -1,8 +1,8 @@ using System.ComponentModel.DataAnnotations; +using Common.Models.Enums; using Microsoft.EntityFrameworkCore; -using Treestar.Shared.Models.Enums; -namespace Treestar.Shared.Models.DBDomain +namespace Common.Models.DBDomain { [Index(nameof(Guid))] public class Novel : BaseEntity diff --git a/Treestar.Shared/Models/DBDomain/Tag.cs b/Common/Models/DBDomain/Tag.cs similarity index 64% rename from Treestar.Shared/Models/DBDomain/Tag.cs rename to Common/Models/DBDomain/Tag.cs index d2ee45c..a1e42d1 100644 --- a/Treestar.Shared/Models/DBDomain/Tag.cs +++ b/Common/Models/DBDomain/Tag.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using Newtonsoft.Json; -namespace Treestar.Shared.Models.DBDomain +namespace Common.Models.DBDomain { public class Tag : BaseEntity { @@ -27,5 +27,20 @@ namespace Treestar.Shared.Models.DBDomain { return TagValue.GetHashCode(); } + + public static Tag GetSiteTag(string siteUrl) + { + return new Tag {TagValue = $"site:{siteUrl.TrimEnd('/')}"}; + } + + public static Tag GetOriginalWorkTag() + { + return new Tag {TagValue = "original_work"}; + } + + public static Tag GetNsfwTag() + { + return new Tag {TagValue = "NSFW"}; + } } } \ No newline at end of file diff --git a/Treestar.Shared/Models/DBDomain/User.cs b/Common/Models/DBDomain/User.cs similarity index 94% rename from Treestar.Shared/Models/DBDomain/User.cs rename to Common/Models/DBDomain/User.cs index 3871e45..e52fe6c 100644 --- a/Treestar.Shared/Models/DBDomain/User.cs +++ b/Common/Models/DBDomain/User.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using Microsoft.EntityFrameworkCore; -namespace Treestar.Shared.Models.DBDomain +namespace Common.Models.DBDomain { [Index(nameof(Email))] public class User : BaseEntity diff --git a/Treestar.Shared/Models/DBDomain/UserNovel.cs b/Common/Models/DBDomain/UserNovel.cs similarity index 95% rename from Treestar.Shared/Models/DBDomain/UserNovel.cs rename to Common/Models/DBDomain/UserNovel.cs index 2fbb07a..813b2fb 100644 --- a/Treestar.Shared/Models/DBDomain/UserNovel.cs +++ b/Common/Models/DBDomain/UserNovel.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Treestar.Shared.Models.DBDomain +namespace Common.Models.DBDomain { public class UserNovel { diff --git a/Treestar.Shared/Models/DTO/Requests/ScrapeNovelRequest.cs b/Common/Models/DTO/Requests/ScrapeNovelRequest.cs similarity index 62% rename from Treestar.Shared/Models/DTO/Requests/ScrapeNovelRequest.cs rename to Common/Models/DTO/Requests/ScrapeNovelRequest.cs index 1b1b89c..fed01b4 100644 --- a/Treestar.Shared/Models/DTO/Requests/ScrapeNovelRequest.cs +++ b/Common/Models/DTO/Requests/ScrapeNovelRequest.cs @@ -1,4 +1,4 @@ -namespace Treestar.Shared.Models.DTO.Requests; +namespace Common.Models.DTO.Requests; public class ScrapeNovelRequest { diff --git a/Treestar.Shared/Models/DTO/Requests/ScrapeNovelsRequest.cs b/Common/Models/DTO/Requests/ScrapeNovelsRequest.cs similarity index 75% rename from Treestar.Shared/Models/DTO/Requests/ScrapeNovelsRequest.cs rename to Common/Models/DTO/Requests/ScrapeNovelsRequest.cs index 60c79c1..35d406d 100644 --- a/Treestar.Shared/Models/DTO/Requests/ScrapeNovelsRequest.cs +++ b/Common/Models/DTO/Requests/ScrapeNovelsRequest.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Treestar.Shared.Models.DTO.Requests; +namespace Common.Models.DTO.Requests; public class ScrapeNovelsRequest { diff --git a/Treestar.Shared/Models/DTO/Responses/ScrapeNovelsResponse.cs b/Common/Models/DTO/Responses/ScrapeNovelsResponse.cs similarity index 64% rename from Treestar.Shared/Models/DTO/Responses/ScrapeNovelsResponse.cs rename to Common/Models/DTO/Responses/ScrapeNovelsResponse.cs index 74c9628..0b35c07 100644 --- a/Treestar.Shared/Models/DTO/Responses/ScrapeNovelsResponse.cs +++ b/Common/Models/DTO/Responses/ScrapeNovelsResponse.cs @@ -1,6 +1,6 @@ -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; -namespace Treestar.Shared.Models.DTO.Responses; +namespace Common.Models.DTO.Responses; public class ScrapeNovelsResponse { diff --git a/Treestar.Shared/Models/Enums/NovelStatus.cs b/Common/Models/Enums/NovelStatus.cs similarity index 67% rename from Treestar.Shared/Models/Enums/NovelStatus.cs rename to Common/Models/Enums/NovelStatus.cs index dfa44ea..70cd2c7 100644 --- a/Treestar.Shared/Models/Enums/NovelStatus.cs +++ b/Common/Models/Enums/NovelStatus.cs @@ -1,4 +1,4 @@ -namespace Treestar.Shared.Models.Enums; +namespace Common.Models.Enums; public enum NovelStatus { diff --git a/Treestar.Shared/Models/HttpResponseWrapper.cs b/Common/Models/HttpResponseWrapper.cs similarity index 85% rename from Treestar.Shared/Models/HttpResponseWrapper.cs rename to Common/Models/HttpResponseWrapper.cs index 595b953..72cf690 100644 --- a/Treestar.Shared/Models/HttpResponseWrapper.cs +++ b/Common/Models/HttpResponseWrapper.cs @@ -1,4 +1,4 @@ -namespace Treestar.Shared.Models; +namespace Common.Models; public class HttpResponseWrapper : HttpResponseWrapper { diff --git a/DBConnection/Contexts/AppDbContext.cs b/DBConnection/Contexts/AppDbContext.cs index 8bb9557..d35b395 100644 --- a/DBConnection/Contexts/AppDbContext.cs +++ b/DBConnection/Contexts/AppDbContext.cs @@ -3,7 +3,7 @@ using DBConnection.ModelBuilders; using DBConnection.Seeders; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Contexts; diff --git a/DBConnection/DBConnection.csproj b/DBConnection/DBConnection.csproj index f0c4ff4..6a0409e 100644 --- a/DBConnection/DBConnection.csproj +++ b/DBConnection/DBConnection.csproj @@ -24,7 +24,7 @@ - + diff --git a/DBConnection/Migrations/PostgresSql/20220716211121_Initial.Designer.cs b/DBConnection/Migrations/PostgresSql/20220716211121_Initial.Designer.cs index 4aa3a4c..c29be6f 100644 --- a/DBConnection/Migrations/PostgresSql/20220716211121_Initial.Designer.cs +++ b/DBConnection/Migrations/PostgresSql/20220716211121_Initial.Designer.cs @@ -39,7 +39,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("NovelTag"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Property("Url") .HasColumnType("text"); @@ -59,7 +59,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Authors"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { b.Property("Url") .HasColumnType("text"); @@ -103,7 +103,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Property("Url") .HasColumnType("text"); @@ -140,7 +140,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => + modelBuilder.Entity("Common.Models.DBDomain.Tag", b => { b.Property("TagValue") .HasColumnType("text"); @@ -156,7 +156,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Tags"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -179,7 +179,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Users"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { b.Property("NovelUrl") .HasColumnType("text"); @@ -199,46 +199,46 @@ namespace DBConnection.Migrations.PostgresSql modelBuilder.Entity("NovelTag", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany() .HasForeignKey("NovelsUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) + b.HasOne("Common.Models.DBDomain.Tag", null) .WithMany() .HasForeignKey("TagsTagValue") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany("Chapters") .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") + b.HasOne("Common.Models.DBDomain.Author", "Author") .WithMany("Novels") .HasForeignKey("AuthorUrl"); b.Navigation("Author"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany() .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") + b.HasOne("Common.Models.DBDomain.User", "User") .WithMany("WatchedNovels") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -249,17 +249,17 @@ namespace DBConnection.Migrations.PostgresSql b.Navigation("User"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Navigation("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Navigation("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Navigation("WatchedNovels"); }); diff --git a/DBConnection/Migrations/PostgresSql/20220716211513_Add index on novel guid.Designer.cs b/DBConnection/Migrations/PostgresSql/20220716211513_Add index on novel guid.Designer.cs index be9ae51..ac5cf57 100644 --- a/DBConnection/Migrations/PostgresSql/20220716211513_Add index on novel guid.Designer.cs +++ b/DBConnection/Migrations/PostgresSql/20220716211513_Add index on novel guid.Designer.cs @@ -39,7 +39,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("NovelTag"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Property("Url") .HasColumnType("text"); @@ -59,7 +59,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Authors"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { b.Property("Url") .HasColumnType("text"); @@ -103,7 +103,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Property("Url") .HasColumnType("text"); @@ -142,7 +142,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => + modelBuilder.Entity("Common.Models.DBDomain.Tag", b => { b.Property("TagValue") .HasColumnType("text"); @@ -158,7 +158,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Tags"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -181,7 +181,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Users"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { b.Property("NovelUrl") .HasColumnType("text"); @@ -201,46 +201,46 @@ namespace DBConnection.Migrations.PostgresSql modelBuilder.Entity("NovelTag", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany() .HasForeignKey("NovelsUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) + b.HasOne("Common.Models.DBDomain.Tag", null) .WithMany() .HasForeignKey("TagsTagValue") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany("Chapters") .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") + b.HasOne("Common.Models.DBDomain.Author", "Author") .WithMany("Novels") .HasForeignKey("AuthorUrl"); b.Navigation("Author"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany() .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") + b.HasOne("Common.Models.DBDomain.User", "User") .WithMany("WatchedNovels") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -251,17 +251,17 @@ namespace DBConnection.Migrations.PostgresSql b.Navigation("User"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Navigation("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Navigation("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Navigation("WatchedNovels"); }); diff --git a/DBConnection/Migrations/PostgresSql/20220717133208_Fix up UserNovel model and add index on User Email.Designer.cs b/DBConnection/Migrations/PostgresSql/20220717133208_Fix up UserNovel model and add index on User Email.Designer.cs index ace620d..ae8c9da 100644 --- a/DBConnection/Migrations/PostgresSql/20220717133208_Fix up UserNovel model and add index on User Email.Designer.cs +++ b/DBConnection/Migrations/PostgresSql/20220717133208_Fix up UserNovel model and add index on User Email.Designer.cs @@ -39,7 +39,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("NovelTag"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Property("Url") .HasColumnType("text"); @@ -59,7 +59,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Authors"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { b.Property("Url") .HasColumnType("text"); @@ -103,7 +103,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Property("Url") .HasColumnType("text"); @@ -142,7 +142,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => + modelBuilder.Entity("Common.Models.DBDomain.Tag", b => { b.Property("TagValue") .HasColumnType("text"); @@ -158,7 +158,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Tags"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -183,7 +183,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Users"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { b.Property("NovelUrl") .HasColumnType("text"); @@ -203,22 +203,22 @@ namespace DBConnection.Migrations.PostgresSql modelBuilder.Entity("NovelTag", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany() .HasForeignKey("NovelsUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) + b.HasOne("Common.Models.DBDomain.Tag", null) .WithMany() .HasForeignKey("TagsTagValue") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany("Chapters") .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) @@ -227,24 +227,24 @@ namespace DBConnection.Migrations.PostgresSql b.Navigation("Novel"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") + b.HasOne("Common.Models.DBDomain.Author", "Author") .WithMany("Novels") .HasForeignKey("AuthorUrl"); b.Navigation("Author"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany() .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") + b.HasOne("Common.Models.DBDomain.User", "User") .WithMany("WatchedNovels") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -255,17 +255,17 @@ namespace DBConnection.Migrations.PostgresSql b.Navigation("User"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Navigation("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Navigation("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Navigation("WatchedNovels"); }); diff --git a/DBConnection/Migrations/PostgresSql/PostgresSqlAppDbContextModelSnapshot.cs b/DBConnection/Migrations/PostgresSql/PostgresSqlAppDbContextModelSnapshot.cs index 83f6c51..5ae1b5e 100644 --- a/DBConnection/Migrations/PostgresSql/PostgresSqlAppDbContextModelSnapshot.cs +++ b/DBConnection/Migrations/PostgresSql/PostgresSqlAppDbContextModelSnapshot.cs @@ -37,7 +37,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("NovelTag"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Property("Url") .HasColumnType("text"); @@ -57,7 +57,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Authors"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { b.Property("Url") .HasColumnType("text"); @@ -101,7 +101,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Property("Url") .HasColumnType("text"); @@ -140,7 +140,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => + modelBuilder.Entity("Common.Models.DBDomain.Tag", b => { b.Property("TagValue") .HasColumnType("text"); @@ -156,7 +156,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Tags"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -181,7 +181,7 @@ namespace DBConnection.Migrations.PostgresSql b.ToTable("Users"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { b.Property("NovelUrl") .HasColumnType("text"); @@ -201,22 +201,22 @@ namespace DBConnection.Migrations.PostgresSql modelBuilder.Entity("NovelTag", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany() .HasForeignKey("NovelsUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) + b.HasOne("Common.Models.DBDomain.Tag", null) .WithMany() .HasForeignKey("TagsTagValue") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany("Chapters") .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) @@ -225,24 +225,24 @@ namespace DBConnection.Migrations.PostgresSql b.Navigation("Novel"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") + b.HasOne("Common.Models.DBDomain.Author", "Author") .WithMany("Novels") .HasForeignKey("AuthorUrl"); b.Navigation("Author"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany() .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") + b.HasOne("Common.Models.DBDomain.User", "User") .WithMany("WatchedNovels") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -253,17 +253,17 @@ namespace DBConnection.Migrations.PostgresSql b.Navigation("User"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Navigation("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Navigation("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Navigation("WatchedNovels"); }); diff --git a/DBConnection/Migrations/Sqlite/20220716210907_Initial.Designer.cs b/DBConnection/Migrations/Sqlite/20220716210907_Initial.Designer.cs index 2eee76e..b180f49 100644 --- a/DBConnection/Migrations/Sqlite/20220716210907_Initial.Designer.cs +++ b/DBConnection/Migrations/Sqlite/20220716210907_Initial.Designer.cs @@ -34,7 +34,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("NovelTag"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -54,7 +54,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Authors"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -98,7 +98,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -135,7 +135,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => + modelBuilder.Entity("Common.Models.DBDomain.Tag", b => { b.Property("TagValue") .HasColumnType("TEXT"); @@ -151,7 +151,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Tags"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -172,7 +172,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Users"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { b.Property("NovelUrl") .HasColumnType("TEXT"); @@ -192,46 +192,46 @@ namespace DBConnection.Migrations.Sqlite modelBuilder.Entity("NovelTag", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany() .HasForeignKey("NovelsUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) + b.HasOne("Common.Models.DBDomain.Tag", null) .WithMany() .HasForeignKey("TagsTagValue") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany("Chapters") .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") + b.HasOne("Common.Models.DBDomain.Author", "Author") .WithMany("Novels") .HasForeignKey("AuthorUrl"); b.Navigation("Author"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany() .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") + b.HasOne("Common.Models.DBDomain.User", "User") .WithMany("WatchedNovels") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -242,17 +242,17 @@ namespace DBConnection.Migrations.Sqlite b.Navigation("User"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Navigation("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Navigation("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Navigation("WatchedNovels"); }); diff --git a/DBConnection/Migrations/Sqlite/20220716211435_Add index on novel guid.Designer.cs b/DBConnection/Migrations/Sqlite/20220716211435_Add index on novel guid.Designer.cs index ba6ff0b..a2e8601 100644 --- a/DBConnection/Migrations/Sqlite/20220716211435_Add index on novel guid.Designer.cs +++ b/DBConnection/Migrations/Sqlite/20220716211435_Add index on novel guid.Designer.cs @@ -34,7 +34,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("NovelTag"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -54,7 +54,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Authors"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -98,7 +98,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -137,7 +137,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => + modelBuilder.Entity("Common.Models.DBDomain.Tag", b => { b.Property("TagValue") .HasColumnType("TEXT"); @@ -153,7 +153,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Tags"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -174,7 +174,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Users"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { b.Property("NovelUrl") .HasColumnType("TEXT"); @@ -194,46 +194,46 @@ namespace DBConnection.Migrations.Sqlite modelBuilder.Entity("NovelTag", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany() .HasForeignKey("NovelsUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) + b.HasOne("Common.Models.DBDomain.Tag", null) .WithMany() .HasForeignKey("TagsTagValue") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany("Chapters") .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") + b.HasOne("Common.Models.DBDomain.Author", "Author") .WithMany("Novels") .HasForeignKey("AuthorUrl"); b.Navigation("Author"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany() .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") + b.HasOne("Common.Models.DBDomain.User", "User") .WithMany("WatchedNovels") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -244,17 +244,17 @@ namespace DBConnection.Migrations.Sqlite b.Navigation("User"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Navigation("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Navigation("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Navigation("WatchedNovels"); }); diff --git a/DBConnection/Migrations/Sqlite/20220717133151_Fix up UserNovel model and add index on User Email.Designer.cs b/DBConnection/Migrations/Sqlite/20220717133151_Fix up UserNovel model and add index on User Email.Designer.cs index 470a978..3b2d403 100644 --- a/DBConnection/Migrations/Sqlite/20220717133151_Fix up UserNovel model and add index on User Email.Designer.cs +++ b/DBConnection/Migrations/Sqlite/20220717133151_Fix up UserNovel model and add index on User Email.Designer.cs @@ -34,7 +34,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("NovelTag"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -54,7 +54,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Authors"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -98,7 +98,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -137,7 +137,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => + modelBuilder.Entity("Common.Models.DBDomain.Tag", b => { b.Property("TagValue") .HasColumnType("TEXT"); @@ -153,7 +153,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Tags"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -176,7 +176,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Users"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { b.Property("NovelUrl") .HasColumnType("TEXT"); @@ -196,22 +196,22 @@ namespace DBConnection.Migrations.Sqlite modelBuilder.Entity("NovelTag", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany() .HasForeignKey("NovelsUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) + b.HasOne("Common.Models.DBDomain.Tag", null) .WithMany() .HasForeignKey("TagsTagValue") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany("Chapters") .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) @@ -220,24 +220,24 @@ namespace DBConnection.Migrations.Sqlite b.Navigation("Novel"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") + b.HasOne("Common.Models.DBDomain.Author", "Author") .WithMany("Novels") .HasForeignKey("AuthorUrl"); b.Navigation("Author"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany() .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") + b.HasOne("Common.Models.DBDomain.User", "User") .WithMany("WatchedNovels") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -248,17 +248,17 @@ namespace DBConnection.Migrations.Sqlite b.Navigation("User"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Navigation("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Navigation("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Navigation("WatchedNovels"); }); diff --git a/DBConnection/Migrations/Sqlite/SqliteAppDbContextModelSnapshot.cs b/DBConnection/Migrations/Sqlite/SqliteAppDbContextModelSnapshot.cs index dda7091..9e128ca 100644 --- a/DBConnection/Migrations/Sqlite/SqliteAppDbContextModelSnapshot.cs +++ b/DBConnection/Migrations/Sqlite/SqliteAppDbContextModelSnapshot.cs @@ -32,7 +32,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("NovelTag"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -52,7 +52,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Authors"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -96,7 +96,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Property("Url") .HasColumnType("TEXT"); @@ -135,7 +135,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => + modelBuilder.Entity("Common.Models.DBDomain.Tag", b => { b.Property("TagValue") .HasColumnType("TEXT"); @@ -151,7 +151,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Tags"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -174,7 +174,7 @@ namespace DBConnection.Migrations.Sqlite b.ToTable("Users"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { b.Property("NovelUrl") .HasColumnType("TEXT"); @@ -194,22 +194,22 @@ namespace DBConnection.Migrations.Sqlite modelBuilder.Entity("NovelTag", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) + b.HasOne("Common.Models.DBDomain.Novel", null) .WithMany() .HasForeignKey("NovelsUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) + b.HasOne("Common.Models.DBDomain.Tag", null) .WithMany() .HasForeignKey("TagsTagValue") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => + modelBuilder.Entity("Common.Models.DBDomain.Chapter", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany("Chapters") .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) @@ -218,24 +218,24 @@ namespace DBConnection.Migrations.Sqlite b.Navigation("Novel"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") + b.HasOne("Common.Models.DBDomain.Author", "Author") .WithMany("Novels") .HasForeignKey("AuthorUrl"); b.Navigation("Author"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => + modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b => { - b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") + b.HasOne("Common.Models.DBDomain.Novel", "Novel") .WithMany() .HasForeignKey("NovelUrl") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") + b.HasOne("Common.Models.DBDomain.User", "User") .WithMany("WatchedNovels") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -246,17 +246,17 @@ namespace DBConnection.Migrations.Sqlite b.Navigation("User"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => + modelBuilder.Entity("Common.Models.DBDomain.Author", b => { b.Navigation("Novels"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => + modelBuilder.Entity("Common.Models.DBDomain.Novel", b => { b.Navigation("Chapters"); }); - modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => + modelBuilder.Entity("Common.Models.DBDomain.User", b => { b.Navigation("WatchedNovels"); }); diff --git a/DBConnection/ModelBuilders/UserNovelBuilder.cs b/DBConnection/ModelBuilders/UserNovelBuilder.cs index a246885..1196ed1 100644 --- a/DBConnection/ModelBuilders/UserNovelBuilder.cs +++ b/DBConnection/ModelBuilders/UserNovelBuilder.cs @@ -1,5 +1,5 @@ using Microsoft.EntityFrameworkCore; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.ModelBuilders; diff --git a/DBConnection/Repositories/AuthorRepository.cs b/DBConnection/Repositories/AuthorRepository.cs index 5ef3009..3f4e136 100644 --- a/DBConnection/Repositories/AuthorRepository.cs +++ b/DBConnection/Repositories/AuthorRepository.cs @@ -1,7 +1,7 @@ using DBConnection.Contexts; using DBConnection.Repositories.Interfaces; using Microsoft.EntityFrameworkCore; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories; diff --git a/DBConnection/Repositories/BaseRepository.cs b/DBConnection/Repositories/BaseRepository.cs index f81e1ee..d9e2361 100644 --- a/DBConnection/Repositories/BaseRepository.cs +++ b/DBConnection/Repositories/BaseRepository.cs @@ -3,7 +3,7 @@ using DBConnection.Contexts; using DBConnection.Repositories.Interfaces; using Microsoft.EntityFrameworkCore; using NuGet.Configuration; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories; diff --git a/DBConnection/Repositories/ChapterRepository.cs b/DBConnection/Repositories/ChapterRepository.cs index d070029..8cf2285 100644 --- a/DBConnection/Repositories/ChapterRepository.cs +++ b/DBConnection/Repositories/ChapterRepository.cs @@ -1,7 +1,7 @@ using DBConnection.Contexts; using DBConnection.Repositories.Interfaces; using Microsoft.EntityFrameworkCore; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories; diff --git a/DBConnection/Repositories/Interfaces/IAuthorRepository.cs b/DBConnection/Repositories/Interfaces/IAuthorRepository.cs index 5737d81..93f6d6f 100644 --- a/DBConnection/Repositories/Interfaces/IAuthorRepository.cs +++ b/DBConnection/Repositories/Interfaces/IAuthorRepository.cs @@ -1,4 +1,4 @@ -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories.Interfaces; diff --git a/DBConnection/Repositories/Interfaces/IChapterRepository.cs b/DBConnection/Repositories/Interfaces/IChapterRepository.cs index a2d7a2d..2f4b42a 100644 --- a/DBConnection/Repositories/Interfaces/IChapterRepository.cs +++ b/DBConnection/Repositories/Interfaces/IChapterRepository.cs @@ -1,4 +1,4 @@ -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories.Interfaces; diff --git a/DBConnection/Repositories/Interfaces/INovelRepository.cs b/DBConnection/Repositories/Interfaces/INovelRepository.cs index dd9f2e2..8a4ea41 100644 --- a/DBConnection/Repositories/Interfaces/INovelRepository.cs +++ b/DBConnection/Repositories/Interfaces/INovelRepository.cs @@ -1,4 +1,4 @@ -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories.Interfaces; diff --git a/DBConnection/Repositories/Interfaces/IRepository.cs b/DBConnection/Repositories/Interfaces/IRepository.cs index 6db87e9..4c84288 100644 --- a/DBConnection/Repositories/Interfaces/IRepository.cs +++ b/DBConnection/Repositories/Interfaces/IRepository.cs @@ -1,4 +1,4 @@ -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories.Interfaces; diff --git a/DBConnection/Repositories/Interfaces/ITagRepository.cs b/DBConnection/Repositories/Interfaces/ITagRepository.cs index 8b779c9..ad20b95 100644 --- a/DBConnection/Repositories/Interfaces/ITagRepository.cs +++ b/DBConnection/Repositories/Interfaces/ITagRepository.cs @@ -1,4 +1,4 @@ -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories.Interfaces; diff --git a/DBConnection/Repositories/Interfaces/IUserRepository.cs b/DBConnection/Repositories/Interfaces/IUserRepository.cs index ed81571..aaeb1fe 100644 --- a/DBConnection/Repositories/Interfaces/IUserRepository.cs +++ b/DBConnection/Repositories/Interfaces/IUserRepository.cs @@ -1,4 +1,4 @@ -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories.Interfaces; diff --git a/DBConnection/Repositories/NovelRepository.cs b/DBConnection/Repositories/NovelRepository.cs index fc44a7e..77930ee 100644 --- a/DBConnection/Repositories/NovelRepository.cs +++ b/DBConnection/Repositories/NovelRepository.cs @@ -1,7 +1,7 @@ using DBConnection.Contexts; using DBConnection.Repositories.Interfaces; using Microsoft.EntityFrameworkCore; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories; diff --git a/DBConnection/Repositories/TagRepository.cs b/DBConnection/Repositories/TagRepository.cs index c287403..436de79 100644 --- a/DBConnection/Repositories/TagRepository.cs +++ b/DBConnection/Repositories/TagRepository.cs @@ -1,7 +1,7 @@ using DBConnection.Contexts; using DBConnection.Repositories.Interfaces; using Microsoft.EntityFrameworkCore; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories; diff --git a/DBConnection/Repositories/UserRepository.cs b/DBConnection/Repositories/UserRepository.cs index df6c488..1b3edcf 100644 --- a/DBConnection/Repositories/UserRepository.cs +++ b/DBConnection/Repositories/UserRepository.cs @@ -1,7 +1,7 @@ using DBConnection.Contexts; using DBConnection.Repositories.Interfaces; using Microsoft.EntityFrameworkCore; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace DBConnection.Repositories; diff --git a/WebNovelPortal.sln b/WebNovelPortal.sln index 98be864..03278e2 100644 --- a/WebNovelPortal.sln +++ b/WebNovelPortal.sln @@ -4,7 +4,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebNovelPortal", "WebNovelP EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebNovelPortalAPI", "WebNovelPortalAPI\WebNovelPortalAPI.csproj", "{D24E3BBA-EAA1-4515-9060-56E673CC7FAA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Treestar.Shared", "Treestar.Shared\Treestar.Shared.csproj", "{639F52AF-9D62-4341-BEE6-0E9243020FC5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{639F52AF-9D62-4341-BEE6-0E9243020FC5}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DBConnection", "DBConnection\DBConnection.csproj", "{CD895518-DA05-4886-BE14-3E04D62FA2F7}" EndProject diff --git a/WebNovelPortal/AccessLayers/WebApiAccessLayer.cs b/WebNovelPortal/AccessLayers/WebApiAccessLayer.cs index 70af227..d5fed5d 100644 --- a/WebNovelPortal/AccessLayers/WebApiAccessLayer.cs +++ b/WebNovelPortal/AccessLayers/WebApiAccessLayer.cs @@ -1,8 +1,8 @@ -using Treestar.Shared.AccessLayers; -using Treestar.Shared.Models.DBDomain; -using Treestar.Shared.Models.DTO; -using Treestar.Shared.Models.DTO.Requests; -using Treestar.Shared.Models.DTO.Responses; +using Common.AccessLayers; +using Common.Models.DBDomain; +using Common.Models.DTO; +using Common.Models.DTO.Requests; +using Common.Models.DTO.Responses; namespace WebNovelPortal.AccessLayers; diff --git a/WebNovelPortal/Authentication/BlazorAccessLayerAuthProvider.cs b/WebNovelPortal/Authentication/BlazorAccessLayerAuthProvider.cs index 50b0c63..7d19e05 100644 --- a/WebNovelPortal/Authentication/BlazorAccessLayerAuthProvider.cs +++ b/WebNovelPortal/Authentication/BlazorAccessLayerAuthProvider.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -using Treestar.Shared.AccessLayers; +using Common.AccessLayers; namespace WebNovelPortal.Authentication; diff --git a/WebNovelPortal/Dockerfile b/WebNovelPortal/Dockerfile index 7ed412d..7e4c57c 100644 --- a/WebNovelPortal/Dockerfile +++ b/WebNovelPortal/Dockerfile @@ -6,7 +6,7 @@ EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ["WebNovelPortal/WebNovelPortal.csproj", "WebNovelPortal/"] -COPY ["Treestar.Shared/Treestar.Shared.csproj", "Treestar.Shared/"] +COPY ["Common/Common.csproj", "Common/"] RUN dotnet restore "WebNovelPortal/WebNovelPortal.csproj" COPY . . WORKDIR "/src/WebNovelPortal" diff --git a/WebNovelPortal/Program.cs b/WebNovelPortal/Program.cs index 18042cd..e2191db 100644 --- a/WebNovelPortal/Program.cs +++ b/WebNovelPortal/Program.cs @@ -2,8 +2,8 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.HttpOverrides; using Newtonsoft.Json; -using Treestar.Shared.AccessLayers; -using Treestar.Shared.Authentication.OIDC; +using Common.AccessLayers; +using Common.Authentication.OIDC; using WebNovelPortal.AccessLayers; using WebNovelPortal.Authentication; diff --git a/WebNovelPortal/WebNovelPortal.csproj b/WebNovelPortal/WebNovelPortal.csproj index 5089395..5002abb 100644 --- a/WebNovelPortal/WebNovelPortal.csproj +++ b/WebNovelPortal/WebNovelPortal.csproj @@ -14,7 +14,7 @@ - + diff --git a/WebNovelPortal/_Imports.razor b/WebNovelPortal/_Imports.razor index 5572ab2..363acf2 100644 --- a/WebNovelPortal/_Imports.razor +++ b/WebNovelPortal/_Imports.razor @@ -11,4 +11,4 @@ @using WebNovelPortal.Shared.Layouts @using WebNovelPortal.Shared.Components.Layout @using WebNovelPortal.Shared.Components.Display -@using Treestar.Shared.Models.DBDomain \ No newline at end of file +@using Common.Models.DBDomain \ No newline at end of file diff --git a/WebNovelPortalAPI/Controllers/AuthorizedController.cs b/WebNovelPortalAPI/Controllers/AuthorizedController.cs index 4a41b55..4fe671e 100644 --- a/WebNovelPortalAPI/Controllers/AuthorizedController.cs +++ b/WebNovelPortalAPI/Controllers/AuthorizedController.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; using WebNovelPortalAPI.Middleware; namespace WebNovelPortalAPI.Controllers diff --git a/WebNovelPortalAPI/Controllers/NovelController.cs b/WebNovelPortalAPI/Controllers/NovelController.cs index f09dfdf..8fdf56b 100644 --- a/WebNovelPortalAPI/Controllers/NovelController.cs +++ b/WebNovelPortalAPI/Controllers/NovelController.cs @@ -8,10 +8,10 @@ using DBConnection.Repositories.Interfaces; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Treestar.Shared.Models.DBDomain; -using Treestar.Shared.Models.DTO; -using Treestar.Shared.Models.DTO.Requests; -using Treestar.Shared.Models.DTO.Responses; +using Common.Models.DBDomain; +using Common.Models.DTO; +using Common.Models.DTO.Requests; +using Common.Models.DTO.Responses; using WebNovelPortalAPI.Exceptions; using WebNovelPortalAPI.Scrapers; @@ -40,7 +40,7 @@ namespace WebNovelPortalAPI.Controllers { throw new NoMatchingScraperException(url); } - var novel = scraper.ScrapeNovel(url); + var novel = await scraper.ScrapeNovel(url); return novel; } diff --git a/WebNovelPortalAPI/Dockerfile b/WebNovelPortalAPI/Dockerfile index 8576262..3ea1adb 100644 --- a/WebNovelPortalAPI/Dockerfile +++ b/WebNovelPortalAPI/Dockerfile @@ -7,7 +7,7 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ["WebNovelPortalAPI/WebNovelPortalAPI.csproj", "WebNovelPortalAPI/"] COPY ["DBConnection/DBConnection.csproj", "DBConnection/"] -COPY ["Treestar.Shared/Treestar.Shared.csproj", "Treestar.Shared/"] +COPY ["Common/Common.csproj", "Common/"] RUN dotnet restore "WebNovelPortalAPI/WebNovelPortalAPI.csproj" COPY . . WORKDIR "/src/WebNovelPortalAPI" diff --git a/WebNovelPortalAPI/Middleware/EnsureUserCreatedMiddleware.cs b/WebNovelPortalAPI/Middleware/EnsureUserCreatedMiddleware.cs index ec08649..29e8f7c 100644 --- a/WebNovelPortalAPI/Middleware/EnsureUserCreatedMiddleware.cs +++ b/WebNovelPortalAPI/Middleware/EnsureUserCreatedMiddleware.cs @@ -1,7 +1,7 @@ using System.Security.Claims; using DBConnection.Repositories.Interfaces; using Microsoft.AspNetCore.Mvc.Filters; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace WebNovelPortalAPI.Middleware; diff --git a/WebNovelPortalAPI/Program.cs b/WebNovelPortalAPI/Program.cs index 9c4e640..385b4b1 100644 --- a/WebNovelPortalAPI/Program.cs +++ b/WebNovelPortalAPI/Program.cs @@ -4,7 +4,7 @@ using DBConnection.Extensions; using Microsoft.EntityFrameworkCore; using Microsoft.OpenApi.Models; using Newtonsoft.Json; -using Treestar.Shared.Authentication.JwtBearer; +using Common.Authentication.JwtBearer; using WebNovelPortalAPI.Extensions; using WebNovelPortalAPI.Middleware; using WebNovelPortalAPI.Scrapers; diff --git a/WebNovelPortalAPI/Scrapers/AbstractScraper.cs b/WebNovelPortalAPI/Scrapers/AbstractScraper.cs index 511c930..579592b 100644 --- a/WebNovelPortalAPI/Scrapers/AbstractScraper.cs +++ b/WebNovelPortalAPI/Scrapers/AbstractScraper.cs @@ -1,11 +1,31 @@ +using System.Net; +using System.Net.Http.Headers; using System.Text.RegularExpressions; using HtmlAgilityPack; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace WebNovelPortalAPI.Scrapers; public abstract class AbstractScraper : IScraper { + protected AbstractScraper() + { + var cookieContainer = new CookieContainer(); + var handler = new HttpClientHandler + { + CookieContainer = cookieContainer + }; + HttpClient client = new HttpClient(handler); + client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Chrome","96.0.4664.110")); + foreach (var cookie in RequestCookies()) + { + cookieContainer.Add(cookie); + } + + HttpClient = client; + } + + protected HttpClient HttpClient { get; } protected abstract string UrlMatchPattern { get; } protected abstract string BaseUrlPattern { get; } protected virtual string? WorkTitlePattern { get; } @@ -19,6 +39,14 @@ public abstract class AbstractScraper : IScraper protected virtual string? DatePostedPattern { get; } protected virtual string? DateUpdatedPattern { get; } + protected async Task GetPage(string url) + { + var response = await HttpClient.GetAsync(url); + var doc = new HtmlDocument(); + doc.LoadHtml(await response.Content.ReadAsStringAsync()); + return doc; + } + protected virtual (DateTime? Posted, DateTime? Updated) GetDateTimeForChapter(HtmlNode linkNode, HtmlNode baseNode, string baseUrl, string novelUrl) { @@ -87,7 +115,7 @@ public abstract class AbstractScraper : IScraper return nodes.Select(node => new Tag { TagValue = node.InnerText - }).ToList(); + }).Union(GetMetadataTags(document, baseUrl, novelUrl)).ToList(); } protected virtual DateTime GetPostedDate(HtmlDocument document, string baseUrl, string novelUrl) @@ -101,18 +129,25 @@ public abstract class AbstractScraper : IScraper var xpath = DateUpdatedPattern; return DateTime.Parse(document.DocumentNode.SelectSingleNode(xpath).InnerText).ToUniversalTime(); } - - public Novel ScrapeNovel(string url) + + protected virtual List RequestCookies() + { + return new List(); + } + + protected abstract IEnumerable GetMetadataTags(HtmlDocument document, string baseUrl, string novelUrl); + + public virtual async Task ScrapeNovel(string url) { - var web = new HtmlWeb(); - var doc = web.Load(url); - if (doc == null) - { - throw new Exception("Error parsing document"); - } var baseUrl = new Regex(BaseUrlPattern).Match(url).Value; var novelUrl = new Regex(UrlMatchPattern).Match(url).Value; + var doc = await GetPage(novelUrl); + if (string.IsNullOrEmpty(doc.Text)) + { + throw new Exception("Error parsing document"); + } + return new Novel { Author = GetAuthor(doc, baseUrl, novelUrl), @@ -125,7 +160,7 @@ public abstract class AbstractScraper : IScraper }; } - public string? ScrapeChapterContent(string chapterUrl) + public Task ScrapeChapterContent(string chapterUrl) { throw new NotImplementedException(); } diff --git a/WebNovelPortalAPI/Scrapers/IScraper.cs b/WebNovelPortalAPI/Scrapers/IScraper.cs index 6bc719d..eaf6b9e 100644 --- a/WebNovelPortalAPI/Scrapers/IScraper.cs +++ b/WebNovelPortalAPI/Scrapers/IScraper.cs @@ -1,11 +1,11 @@ -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; namespace WebNovelPortalAPI.Scrapers; public interface IScraper { public bool MatchesUrl(string url); - public Novel ScrapeNovel(string url); - public string? ScrapeChapterContent(string chapterUrl); + public Task ScrapeNovel(string url); + public Task ScrapeChapterContent(string chapterUrl); } \ No newline at end of file diff --git a/WebNovelPortalAPI/Scrapers/KakuyomuScraper.cs b/WebNovelPortalAPI/Scrapers/KakuyomuScraper.cs index 96363f1..91f9e49 100644 --- a/WebNovelPortalAPI/Scrapers/KakuyomuScraper.cs +++ b/WebNovelPortalAPI/Scrapers/KakuyomuScraper.cs @@ -1,5 +1,6 @@ using System.Reflection.Metadata; using System.Text.RegularExpressions; +using Common.Models.DBDomain; using HtmlAgilityPack; namespace WebNovelPortalAPI.Scrapers; @@ -34,4 +35,13 @@ public class KakuyomuScraper : AbstractScraper var datePosted = linkNode.SelectSingleNode(ChapterPostedPattern).Attributes["datetime"].Value; return (DateTime.Parse(datePosted).ToUniversalTime(), null); } + + protected override IEnumerable GetMetadataTags(HtmlDocument document, string baseUrl, string novelUrl) + { + return new List + { + Tag.GetSiteTag(baseUrl), + Tag.GetOriginalWorkTag() + }; + } } \ No newline at end of file diff --git a/WebNovelPortalAPI/Scrapers/SyosetuScraper.cs b/WebNovelPortalAPI/Scrapers/SyosetuScraper.cs index f1acd8f..713d0f3 100644 --- a/WebNovelPortalAPI/Scrapers/SyosetuScraper.cs +++ b/WebNovelPortalAPI/Scrapers/SyosetuScraper.cs @@ -1,15 +1,17 @@ +using System.Net; using System.Text.RegularExpressions; using HtmlAgilityPack; -using Treestar.Shared.Models.DBDomain; +using Common.Models.DBDomain; +using Common.Models.Enums; namespace WebNovelPortalAPI.Scrapers; public class SyosetuScraper : AbstractScraper { - protected override string UrlMatchPattern => @"https?:\/\/\w+\.syosetu\.com\/\w+\/?"; + protected override string UrlMatchPattern => @"https?:\/\/(\w+)\.syosetu\.com\/\w+\/?"; - protected override string BaseUrlPattern => @"https?:\/\/\w+\.syosetu\.com"; + protected override string BaseUrlPattern => @"https?:\/\/(\w+)\.syosetu\.com"; protected override string? WorkTitlePattern => @"//p[@class='novel_title']"; @@ -29,14 +31,14 @@ public class SyosetuScraper : AbstractScraper protected override string? DateUpdatedPattern => @"//th[contains(text(),'掲載日')]/following-sibling::td"; - private HtmlDocument? GetInfoPage(string baseUrl, string novelUrl) + private async Task GetInfoPage(string baseUrl, string novelUrl) { string novelInfoBase = $"/novelview/infotop/ncode/"; string novelRegex = @"https?:\/\/\w+\.syosetu\.com\/(\w+)\/?"; string novelCode = new Regex(novelRegex).Match(novelUrl).Groups[1].Value; string novelInfoPage = $"{baseUrl}{novelInfoBase}{novelCode}"; - var web = new HtmlWeb(); - return web.Load(novelInfoPage); + return await GetPage(novelInfoPage); + } protected override List GetChapters(HtmlDocument document, string baseUrl, string novelUrl) @@ -85,35 +87,86 @@ public class SyosetuScraper : AbstractScraper protected override DateTime GetPostedDate(HtmlDocument document, string baseUrl, string novelUrl) { - var doc = GetInfoPage(baseUrl, novelUrl); - if (doc == null) - { - return DateTime.MinValue; - } - - var node = doc.DocumentNode.SelectSingleNode(DatePostedPattern); + var node = document.DocumentNode.SelectSingleNode(DatePostedPattern); return DateTime.Parse(node.InnerText).ToUniversalTime(); } protected override DateTime GetLastUpdatedDate(HtmlDocument document, string baseUrl, string novelUrl) { - var doc = GetInfoPage(baseUrl, novelUrl); - if (doc == null) - { - return DateTime.MinValue; - } - return DateTime.Parse(doc.DocumentNode.SelectNodes(DateUpdatedPattern)[1].InnerText).ToUniversalTime(); + return DateTime.Parse(document.DocumentNode.SelectNodes(DateUpdatedPattern)[1].InnerText).ToUniversalTime(); } protected override List GetTags(HtmlDocument document, string baseUrl, string novelUrl) { - var doc = GetInfoPage(baseUrl, novelUrl); - if (doc == null) + var tags = document.DocumentNode.SelectSingleNode(TagPattern).InnerText.Replace("\n", "").Replace(" ", " ").Split(' '); + return tags.Select(i => new Tag {TagValue = i}).Union(GetMetadataTags(document, baseUrl, novelUrl)).ToList(); + } + + protected override List RequestCookies() + { + var domain = ".syosetu.com"; + return new List { - return new List(); + new Cookie + { + Domain = domain, + Name = "over18", + Value = "yes" + } + }; + } + + protected override IEnumerable GetMetadataTags(HtmlDocument document, string baseUrl, string novelUrl) + { + bool nsfw = Regex.Match(baseUrl, BaseUrlPattern).Groups[1].Value == "novel18"; + var tags = new List + { + Tag.GetSiteTag(baseUrl), + Tag.GetOriginalWorkTag() + }; + if (nsfw) + { + tags.Add(Tag.GetNsfwTag()); } - var tags = doc.DocumentNode.SelectSingleNode(TagPattern).InnerText.Replace("\n", "").Replace(" ", " ").Split(' '); - return tags.Select(i => new Tag {TagValue = i}).ToList(); + return tags; + } + + public override async Task ScrapeNovel(string url) + { + var baseUrl = new Regex(BaseUrlPattern).Match(url).Value; + var novelUrl = new Regex(UrlMatchPattern).Match(url).Value; + HtmlDocument baseDoc; + HtmlDocument novelInfoPage; + try + { + baseDoc = await GetPage(novelUrl); + novelInfoPage = await GetInfoPage(baseUrl, novelUrl); + } + catch (Exception e) + { + throw new Exception("Error parsing document"); + } + + return new Novel + { + Title = GetNovelTitle(baseDoc, + baseUrl, + novelUrl), + Author = GetAuthor(baseDoc, + baseUrl, + novelUrl), + Chapters = GetChapters(baseDoc, + baseUrl, + novelUrl), + LastUpdated = GetLastUpdatedDate(novelInfoPage, baseUrl, novelUrl), + Tags = GetTags(novelInfoPage, + baseUrl, + novelUrl), + DatePosted = GetPostedDate(novelInfoPage, + baseUrl, + novelUrl), + Url = novelUrl + }; } } \ No newline at end of file diff --git a/WebNovelPortalAPI/WebNovelPortalAPI.csproj b/WebNovelPortalAPI/WebNovelPortalAPI.csproj index 911db18..c8c8c50 100644 --- a/WebNovelPortalAPI/WebNovelPortalAPI.csproj +++ b/WebNovelPortalAPI/WebNovelPortalAPI.csproj @@ -24,7 +24,7 @@ - +