diff --git a/src/Web/Features/Contents/Data/ContentDbContext.cs b/src/Web/Features/Contents/Data/ContentDbContext.cs index 8ebc843..994d6e7 100644 --- a/src/Web/Features/Contents/Data/ContentDbContext.cs +++ b/src/Web/Features/Contents/Data/ContentDbContext.cs @@ -49,8 +49,8 @@ public class ContentDbContext( modelBuilder .Entity() - .OwnsOne(x => x.ProfileColors) - .ToTable(nameof(ProfileColors)); + .OwnsOne(x => x.Colors) + .ToTable(nameof(Colors)); modelBuilder .Entity() diff --git a/src/Web/Features/Contents/Data/Creator.cs b/src/Web/Features/Contents/Data/Creator.cs index 689b1d8..75f5c50 100644 --- a/src/Web/Features/Contents/Data/Creator.cs +++ b/src/Web/Features/Contents/Data/Creator.cs @@ -11,7 +11,7 @@ public class Creator public About About { get; set; } = new(); public Socials Socials { get; set; } = new(); - public ProfileColors ProfileColors { get; set; } = new(); + public Colors Colors { get; set; } = new(); public Images Images { get; set; } = new(); } @@ -21,7 +21,7 @@ public class About [MaxLength(2048)] public string? Description { get; set; } } -public class ProfileColors +public class Colors { [MaxLength(9)] public string? BannerTop { get; set; } [MaxLength(9)] public string? BannerBottom { get; set; } diff --git a/src/Web/Features/Contents/Handlers/ChangeColors.cs b/src/Web/Features/Contents/Handlers/ChangeColors.cs index 226b61a..d08aaf0 100644 --- a/src/Web/Features/Contents/Handlers/ChangeColors.cs +++ b/src/Web/Features/Contents/Handlers/ChangeColors.cs @@ -53,15 +53,15 @@ public class ChangeColorsHandler( { var creator = await context .Creators - .Include(c => c.ProfileColors) + .Include(c => c.Colors) .SingleAsync( c => c.Id == request.CreatorId, cancellationToken: ct); - creator.ProfileColors.BannerTop = request.BannerTop; - creator.ProfileColors.BannerBottom = request.BannerBottom; - creator.ProfileColors.Accent = request.Accent; - creator.ProfileColors.Menu = request.Menu; + creator.Colors.BannerTop = request.BannerTop; + creator.Colors.BannerBottom = request.BannerBottom; + creator.Colors.Accent = request.Accent; + creator.Colors.Menu = request.Menu; await context.SaveChangesAsync(ct); diff --git a/src/Web/Features/Contents/Handlers/ChangeSocials.cs b/src/Web/Features/Contents/Handlers/ChangeSocials.cs index 62d6848..8c11aa4 100644 --- a/src/Web/Features/Contents/Handlers/ChangeSocials.cs +++ b/src/Web/Features/Contents/Handlers/ChangeSocials.cs @@ -29,7 +29,7 @@ public class ChangeSocialsHandler( { var creator = await context .Creators - .Include(c => c.ProfileColors) + .Include(c => c.Socials) .SingleAsync( c => c.Id == request.CreatorId, cancellationToken: ct); diff --git a/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs b/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs index fe5d8e5..0287b4e 100644 --- a/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs +++ b/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs @@ -62,7 +62,7 @@ public class GetCreatorByAliasHandler( Name = creator.Name, About = creator.About, Socials = creator.Socials, - ProfileColors = creator.ProfileColors, + Colors = creator.Colors, Images = creator.Images, SubscriberCount = subscriberCount, }; diff --git a/src/Web/Features/Contents/Handlers/Models/CreatorModel.cs b/src/Web/Features/Contents/Handlers/Models/CreatorModel.cs index e59db4e..b53bcea 100644 --- a/src/Web/Features/Contents/Handlers/Models/CreatorModel.cs +++ b/src/Web/Features/Contents/Handlers/Models/CreatorModel.cs @@ -10,7 +10,7 @@ public class CreatorModel public string Name { get; set; } public About About { get; set; } public Socials Socials { get; set; } - public ProfileColors ProfileColors { get; set; } + public Colors Colors { get; set; } public Images Images { get; set; } public int SubscriberCount { get; set; } } diff --git a/src/Web/Features/Contents/Migrations/20240806050040_Initial.Designer.cs b/src/Web/Features/Contents/Migrations/20240806065219_Initial.Designer.cs similarity index 97% rename from src/Web/Features/Contents/Migrations/20240806050040_Initial.Designer.cs rename to src/Web/Features/Contents/Migrations/20240806065219_Initial.Designer.cs index 7c9d53c..76dc6e2 100644 --- a/src/Web/Features/Contents/Migrations/20240806050040_Initial.Designer.cs +++ b/src/Web/Features/Contents/Migrations/20240806065219_Initial.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Hutopy.Web.Features.Contents.Migrations { [DbContext(typeof(ContentDbContext))] - [Migration("20240806050040_Initial")] + [Migration("20240806065219_Initial")] partial class Initial { /// @@ -134,28 +134,7 @@ namespace Hutopy.Web.Features.Contents.Migrations .HasForeignKey("CreatorId"); }); - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Banner") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("Logo") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Images", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.ProfileColors", "ProfileColors", b1 => + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => { b1.Property("CreatorId") .HasColumnType("uuid"); @@ -178,7 +157,28 @@ namespace Hutopy.Web.Features.Contents.Migrations b1.HasKey("CreatorId"); - b1.ToTable("ProfileColors", "Content"); + b1.ToTable("Colors", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Banner") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("Logo") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Images", "Content"); b1.WithOwner() .HasForeignKey("CreatorId"); @@ -232,10 +232,10 @@ namespace Hutopy.Web.Features.Contents.Migrations b.Navigation("About") .IsRequired(); - b.Navigation("Images") + b.Navigation("Colors") .IsRequired(); - b.Navigation("ProfileColors") + b.Navigation("Images") .IsRequired(); b.Navigation("Socials") diff --git a/src/Web/Features/Contents/Migrations/20240806050040_Initial.cs b/src/Web/Features/Contents/Migrations/20240806065219_Initial.cs similarity index 97% rename from src/Web/Features/Contents/Migrations/20240806050040_Initial.cs rename to src/Web/Features/Contents/Migrations/20240806065219_Initial.cs index 2563d7c..6ceb9b5 100644 --- a/src/Web/Features/Contents/Migrations/20240806050040_Initial.cs +++ b/src/Web/Features/Contents/Migrations/20240806065219_Initial.cs @@ -31,6 +31,29 @@ namespace Hutopy.Web.Features.Contents.Migrations table.PrimaryKey("PK_Creators", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Colors", + schema: "Content", + columns: table => new + { + CreatorId = table.Column(type: "uuid", nullable: false), + BannerTop = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), + BannerBottom = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), + Accent = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), + Menu = table.Column(type: "character varying(9)", maxLength: 9, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Colors", x => x.CreatorId); + table.ForeignKey( + name: "FK_Colors_Creators_CreatorId", + column: x => x.CreatorId, + principalSchema: "Content", + principalTable: "Creators", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "Contents", schema: "Content", @@ -76,29 +99,6 @@ namespace Hutopy.Web.Features.Contents.Migrations onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "ProfileColors", - schema: "Content", - columns: table => new - { - CreatorId = table.Column(type: "uuid", nullable: false), - BannerTop = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), - BannerBottom = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), - Accent = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), - Menu = table.Column(type: "character varying(9)", maxLength: 9, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ProfileColors", x => x.CreatorId); - table.ForeignKey( - name: "FK_ProfileColors_Creators_CreatorId", - column: x => x.CreatorId, - principalSchema: "Content", - principalTable: "Creators", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "Socials", schema: "Content", @@ -163,6 +163,10 @@ namespace Hutopy.Web.Features.Contents.Migrations /// protected override void Down(MigrationBuilder migrationBuilder) { + migrationBuilder.DropTable( + name: "Colors", + schema: "Content"); + migrationBuilder.DropTable( name: "Contents", schema: "Content"); @@ -171,10 +175,6 @@ namespace Hutopy.Web.Features.Contents.Migrations name: "Images", schema: "Content"); - migrationBuilder.DropTable( - name: "ProfileColors", - schema: "Content"); - migrationBuilder.DropTable( name: "Socials", schema: "Content"); diff --git a/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs b/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs index f50bd25..245416b 100644 --- a/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs +++ b/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs @@ -131,28 +131,7 @@ namespace Hutopy.Web.Features.Contents.Migrations .HasForeignKey("CreatorId"); }); - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Banner") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("Logo") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Images", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.ProfileColors", "ProfileColors", b1 => + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => { b1.Property("CreatorId") .HasColumnType("uuid"); @@ -175,7 +154,28 @@ namespace Hutopy.Web.Features.Contents.Migrations b1.HasKey("CreatorId"); - b1.ToTable("ProfileColors", "Content"); + b1.ToTable("Colors", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Banner") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("Logo") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Images", "Content"); b1.WithOwner() .HasForeignKey("CreatorId"); @@ -229,10 +229,10 @@ namespace Hutopy.Web.Features.Contents.Migrations b.Navigation("About") .IsRequired(); - b.Navigation("Images") + b.Navigation("Colors") .IsRequired(); - b.Navigation("ProfileColors") + b.Navigation("Images") .IsRequired(); b.Navigation("Socials") diff --git a/src/Web/TestDataSeeder.cs b/src/Web/TestDataSeeder.cs index f1b3189..68bc5e5 100644 --- a/src/Web/TestDataSeeder.cs +++ b/src/Web/TestDataSeeder.cs @@ -189,7 +189,7 @@ internal class TestDataSeeder( Title = "Page officielle", Description = "Site officiel pour Hutopy. Venez-nous-y retrouver avec tous vos fans!", }, - ProfileColors = new() + Colors = new() { BannerTop = "#A30E79", BannerBottom = "#6B0065", Accent = "#23393B", Menu = "#53B93B", }, @@ -216,7 +216,7 @@ internal class TestDataSeeder( Title = "Page officielle", Description = "Site officiel pour Arps. Venez-nous-y retrouver avec tous vos fans!", }, - ProfileColors = + Colors = new() { BannerTop = "#231F20", BannerBottom = "#231F20", Accent = "#272526", Menu = "#FFFFFF" }, Socials = new() { @@ -242,7 +242,7 @@ internal class TestDataSeeder( Title = "Page officielle", Description = "𝐿𝑎 𝑐𝑟𝑒́𝑎𝑡𝑖𝑣𝑖𝑡𝑒́ 𝑐’𝑒𝑠𝑡 𝑙’𝑖𝑛𝑡𝑒𝑙𝑙𝑖𝑔𝑒𝑛𝑐𝑒 𝑞𝑢𝑖 𝑠’𝑎𝑚𝑢𝑠𝑒!", }, - ProfileColors = new() + Colors = new() { BannerTop = "#231F20", BannerBottom = "#272526", Accent = "#231F20", Menu = "#231F20", }, @@ -268,7 +268,7 @@ internal class TestDataSeeder( Description = "Mettre en lumière le côté humain des entrepreneurs. Chaque service, chaque produit est porteur d’une histoire, d’une passion, d’une vision unique. Mon objectif est de faire rayonner cette unicité, de créer des connexions authentiques entre ces entrepreneurs et leurs clients potentiels. Parce que derrière chaque entreprise, il y a des personnes inspirantes qui méritent d’être entendues et comprises. Et toi, quel est ton objectif pour cette année?", }, - ProfileColors = new() + Colors = new() { BannerTop = "#0BAAB2", BannerBottom = "#006D77", Accent = "#CC6F91", Menu = "#CC6F91", }, @@ -296,7 +296,7 @@ internal class TestDataSeeder( Description = "Mettre en lumière le côté humain des entrepreneurs. Chaque service, chaque produit est porteur d’une histoire, d’une passion, d’une vision unique. Mon objectif est de faire rayonner cette unicité, de créer des connexions authentiques entre ces entrepreneurs et leurs clients potentiels. Parce que derrière chaque entreprise, il y a des personnes inspirantes qui méritent d’être entendues et comprises. Et toi, quel est ton objectif pour cette année?", }, - ProfileColors = new() + Colors = new() { BannerTop = "#CC6F91", BannerBottom = "#FBC702", Accent = "#FBC702", Menu = "#FBC702", }, @@ -323,7 +323,7 @@ internal class TestDataSeeder( Description = "Mettre en lumière le côté humain des entrepreneurs. Chaque service, chaque produit est porteur d’une histoire, d’une passion, d’une vision unique. Mon objectif est de faire rayonner cette unicité, de créer des connexions authentiques entre ces entrepreneurs et leurs clients potentiels. Parce que derrière chaque entreprise, il y a des personnes inspirantes qui méritent d’être entendues et comprises. Et toi, quel est ton objectif pour cette année?", }, - ProfileColors = new() + Colors = new() { BannerTop = "#101B49", BannerBottom = "#698FE7", Accent = "#1D1D1B", Menu = "#1D1D1B", },