Remove colors
This commit is contained in:
@@ -51,11 +51,6 @@ public class ContentDbContext(
|
||||
.OwnsOne<Socials>(x => x.Socials)
|
||||
.ToTable(nameof(Socials));
|
||||
|
||||
modelBuilder
|
||||
.Entity<Creator>()
|
||||
.OwnsOne<Colors>(x => x.Colors)
|
||||
.ToTable(nameof(Colors));
|
||||
|
||||
modelBuilder
|
||||
.Entity<Creator>()
|
||||
.OwnsOne<Images>(x => x.Images)
|
||||
|
||||
@@ -12,25 +12,10 @@ public class Creator
|
||||
public Slugs Slugs { get; set; } = null!;
|
||||
[MaxLength(255)] public string? Title { get; set; }
|
||||
public Socials Socials { get; set; } = new();
|
||||
public Colors Colors { get; set; } = new();
|
||||
public Images Images { get; set; } = new();
|
||||
public PresentationInfos PresentationInfos { get; set; } = new();
|
||||
}
|
||||
|
||||
public class Colors
|
||||
{
|
||||
[MaxLength(9)] public string Primary { get; set; } = null!;
|
||||
[MaxLength(9)] public string Secondary { get; set; } = null!;
|
||||
[MaxLength(9)] public string Background { get; set; } = null!;
|
||||
[MaxLength(9)] public string Surface { get; set; } = null!;
|
||||
[MaxLength(9)] public string Error { get; set; } = null!;
|
||||
[MaxLength(9)] public string OnPrimary { get; set; } = null!;
|
||||
[MaxLength(9)] public string OnSecondary { get; set; } = null!;
|
||||
[MaxLength(9)] public string OnBackground { get; set; } = null!;
|
||||
[MaxLength(9)] public string OnSurface { get; set; } = null!;
|
||||
[MaxLength(9)] public string OnError { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class Socials
|
||||
{
|
||||
[MaxLength(255)] public string? FacebookUrl { get; set; }
|
||||
|
||||
376
backend/src/Web/Features/Contents/Data/Migrations/20250208043324_RemoveColors.Designer.cs
generated
Normal file
376
backend/src/Web/Features/Contents/Data/Migrations/20250208043324_RemoveColors.Designer.cs
generated
Normal file
@@ -0,0 +1,376 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(ContentDbContext))]
|
||||
[Migration("20250208043324_RemoveColors")]
|
||||
partial class RemoveColors
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasDefaultSchema("Content")
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid?>("DeletedBy")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("character varying(2048)");
|
||||
|
||||
b.Property<string>("HtmlFileUrl")
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("character varying(2048)");
|
||||
|
||||
b.Property<string>("ThumbnailUrl")
|
||||
.HasMaxLength(512)
|
||||
.HasColumnType("character varying(512)");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b.Property<string[]>("Urls")
|
||||
.HasColumnType("text[]");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CreatedBy");
|
||||
|
||||
b.ToTable("Contents", "Content");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("AcceptDonation")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SlugsId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b.Property<bool>("Verified")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SlugsId");
|
||||
|
||||
b.ToTable("Creators", "Content");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Slugs", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("Active")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.IsRequired()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)")
|
||||
.HasComputedColumnSql("LOWER( \"Content\".\"Slugs\".\"Name\")", true);
|
||||
|
||||
b.Property<DateTimeOffset>("ReservedUntil")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Slugs", "Content");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b =>
|
||||
{
|
||||
b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator")
|
||||
.WithMany()
|
||||
.HasForeignKey("CreatedBy")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.OwnsMany("Hutopy.Web.Features.Contents.Data.ContentReaction", "Reactions", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("ContentId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b1.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property<int>("Id"));
|
||||
|
||||
b1.Property<int>("Reaction")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b1.Property<string>("UserName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.HasKey("ContentId", "Id");
|
||||
|
||||
b1.ToTable("Reactions", "Content");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("ContentId");
|
||||
});
|
||||
|
||||
b.Navigation("Creator");
|
||||
|
||||
b.Navigation("Reactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b =>
|
||||
{
|
||||
b.HasOne("Hutopy.Web.Features.Contents.Data.Slugs", "Slugs")
|
||||
.WithMany()
|
||||
.HasForeignKey("SlugsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("CreatorId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b1.Property<string>("Banner")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.Property<string>("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.PresentationInfos", "PresentationInfos", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("CreatorId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b1.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.Property<string>("Image1Url")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.Property<string>("Image2Url")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.Property<string>("Image3Url")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.Property<string>("Image4Url")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.Property<string>("ImagesSubtitle")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.Property<string>("ImagesText")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10000)
|
||||
.HasColumnType("character varying(10000)");
|
||||
|
||||
b1.Property<string>("MainImageText")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10000)
|
||||
.HasColumnType("character varying(10000)");
|
||||
|
||||
b1.Property<string>("MainImageUrl")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.Property<string>("MainVideoText")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10000)
|
||||
.HasColumnType("character varying(10000)");
|
||||
|
||||
b1.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.Property<string>("VideoSubtitle")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.Property<string>("VideoSubtitleMain")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.Property<string>("VideoText")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10000)
|
||||
.HasColumnType("character varying(10000)");
|
||||
|
||||
b1.Property<string>("VideoUrl")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.Property<string>("VideoUrlMain")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b1.HasKey("CreatorId");
|
||||
|
||||
b1.ToTable("PresentationInfos", "Content");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("CreatorId");
|
||||
});
|
||||
|
||||
b.OwnsOne("Hutopy.Web.Features.Contents.Data.Socials", "Socials", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("CreatorId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b1.Property<string>("FacebookUrl")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.Property<string>("InstagramUrl")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.Property<string>("LinkedInUrl")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.Property<string>("RedditUrl")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.Property<string>("TikTokUrl")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.Property<string>("WebsiteUrl")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.Property<string>("XUrl")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.Property<string>("YoutubeUrl")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b1.HasKey("CreatorId");
|
||||
|
||||
b1.ToTable("Socials", "Content");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("CreatorId");
|
||||
});
|
||||
|
||||
b.Navigation("Images")
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PresentationInfos")
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Slugs");
|
||||
|
||||
b.Navigation("Socials")
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RemoveColors : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Colors",
|
||||
schema: "Content");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Colors",
|
||||
schema: "Content",
|
||||
columns: table => new
|
||||
{
|
||||
CreatorId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Background = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
Error = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
OnBackground = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
OnError = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
OnPrimary = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
OnSecondary = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
OnSurface = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
Primary = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
Secondary = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
Surface = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false)
|
||||
},
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,69 +192,6 @@ namespace Hutopy.Web.Features.Contents.Data.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("CreatorId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b1.Property<string>("Background")
|
||||
.IsRequired()
|
||||
.HasMaxLength(9)
|
||||
.HasColumnType("character varying(9)");
|
||||
|
||||
b1.Property<string>("Error")
|
||||
.IsRequired()
|
||||
.HasMaxLength(9)
|
||||
.HasColumnType("character varying(9)");
|
||||
|
||||
b1.Property<string>("OnBackground")
|
||||
.IsRequired()
|
||||
.HasMaxLength(9)
|
||||
.HasColumnType("character varying(9)");
|
||||
|
||||
b1.Property<string>("OnError")
|
||||
.IsRequired()
|
||||
.HasMaxLength(9)
|
||||
.HasColumnType("character varying(9)");
|
||||
|
||||
b1.Property<string>("OnPrimary")
|
||||
.IsRequired()
|
||||
.HasMaxLength(9)
|
||||
.HasColumnType("character varying(9)");
|
||||
|
||||
b1.Property<string>("OnSecondary")
|
||||
.IsRequired()
|
||||
.HasMaxLength(9)
|
||||
.HasColumnType("character varying(9)");
|
||||
|
||||
b1.Property<string>("OnSurface")
|
||||
.IsRequired()
|
||||
.HasMaxLength(9)
|
||||
.HasColumnType("character varying(9)");
|
||||
|
||||
b1.Property<string>("Primary")
|
||||
.IsRequired()
|
||||
.HasMaxLength(9)
|
||||
.HasColumnType("character varying(9)");
|
||||
|
||||
b1.Property<string>("Secondary")
|
||||
.IsRequired()
|
||||
.HasMaxLength(9)
|
||||
.HasColumnType("character varying(9)");
|
||||
|
||||
b1.Property<string>("Surface")
|
||||
.IsRequired()
|
||||
.HasMaxLength(9)
|
||||
.HasColumnType("character varying(9)");
|
||||
|
||||
b1.HasKey("CreatorId");
|
||||
|
||||
b1.ToTable("Colors", "Content");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("CreatorId");
|
||||
});
|
||||
|
||||
b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("CreatorId")
|
||||
@@ -419,9 +356,6 @@ namespace Hutopy.Web.Features.Contents.Data.Migrations
|
||||
.HasForeignKey("CreatorId");
|
||||
});
|
||||
|
||||
b.Navigation("Colors")
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Images")
|
||||
.IsRequired();
|
||||
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public record ChangeColorsRequest(
|
||||
Guid CreatorId,
|
||||
string Primary,
|
||||
string Secondary,
|
||||
string Background,
|
||||
string Surface,
|
||||
string Error,
|
||||
string OnPrimary,
|
||||
string OnSecondary,
|
||||
string OnBackground,
|
||||
string OnSurface,
|
||||
string OnError);
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class ChangeColorsRequestValidator
|
||||
: Validator<ChangeColorsRequest>
|
||||
{
|
||||
public ChangeColorsRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.Primary)
|
||||
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
|
||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
||||
|
||||
RuleFor(x => x.Secondary)
|
||||
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
|
||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
||||
|
||||
RuleFor(x => x.Background)
|
||||
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
|
||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
||||
|
||||
RuleFor(x => x.Surface)
|
||||
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
|
||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
||||
|
||||
RuleFor(x => x.Error)
|
||||
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
|
||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
||||
|
||||
RuleFor(x => x.OnPrimary)
|
||||
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
|
||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
||||
|
||||
RuleFor(x => x.OnSecondary)
|
||||
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
|
||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
||||
|
||||
RuleFor(x => x.OnBackground)
|
||||
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
|
||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
||||
|
||||
RuleFor(x => x.OnSurface)
|
||||
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
|
||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
||||
|
||||
RuleFor(x => x.OnError)
|
||||
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
|
||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
||||
}
|
||||
}
|
||||
|
||||
public class ChangeColorsHandler(
|
||||
ContentDbContext context)
|
||||
: Endpoint<ChangeColorsRequest>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/creators/{CreatorId}/colors");
|
||||
Options(o => o.WithTags("Creators"));
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(
|
||||
ChangeColorsRequest request,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var creator = await context
|
||||
.Creators
|
||||
.Include(c => c.Colors)
|
||||
.SingleAsync(
|
||||
c => c.Id == request.CreatorId,
|
||||
cancellationToken: ct);
|
||||
|
||||
creator.Colors.Primary = request.Primary;
|
||||
creator.Colors.Secondary = request.Secondary;
|
||||
creator.Colors.Background = request.Background;
|
||||
creator.Colors.Surface = request.Surface;
|
||||
creator.Colors.Error = request.Error;
|
||||
creator.Colors.OnPrimary = request.OnPrimary;
|
||||
creator.Colors.OnSecondary = request.OnSecondary;
|
||||
creator.Colors.OnBackground = request.OnBackground;
|
||||
creator.Colors.OnSurface = request.OnSurface;
|
||||
creator.Colors.OnError = request.OnError;
|
||||
|
||||
await context.SaveChangesAsync(ct);
|
||||
|
||||
await SendOkAsync(ct);
|
||||
}
|
||||
}
|
||||
@@ -63,20 +63,7 @@ public sealed class CreateCreatorHandler(
|
||||
{
|
||||
Id = req.CreatorId,
|
||||
CreatedBy = User.GetUserId(),
|
||||
Slugs = slug,
|
||||
Colors =
|
||||
{
|
||||
Primary = "#A30E79",
|
||||
Secondary = "#6B0065",
|
||||
Background = "#ffffff",
|
||||
Surface = "#50f050",
|
||||
Error = "#B00020",
|
||||
OnPrimary = "#ffffff",
|
||||
OnSecondary = "#000000",
|
||||
OnBackground = "#000000",
|
||||
OnSurface = "#000000",
|
||||
OnError = "#ffffff",
|
||||
}
|
||||
Slugs = slug
|
||||
},
|
||||
ct);
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ public class GetCreatorByAliasResponse(
|
||||
string name,
|
||||
string? title,
|
||||
Socials socials,
|
||||
Colors colors,
|
||||
PresentationInfos presentationInfos,
|
||||
Images images)
|
||||
{
|
||||
@@ -30,7 +29,6 @@ public class GetCreatorByAliasResponse(
|
||||
public string Name { get; } = name;
|
||||
public string? Title { get; } = title;
|
||||
public Socials Socials { get; } = socials;
|
||||
public Colors Colors { get; } = colors;
|
||||
public PresentationInfos PresentationInfos { get; } = presentationInfos;
|
||||
public Images Images { get; } = images;
|
||||
}
|
||||
@@ -79,7 +77,6 @@ public class GetCreatorByAliasHandler(
|
||||
c.Slugs.NormalizedName,
|
||||
c.Title,
|
||||
c.Socials,
|
||||
c.Colors,
|
||||
c.PresentationInfos,
|
||||
c.Images))
|
||||
.SingleOrDefaultAsync(ct);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Common.Security;
|
||||
using Hutopy.Web.Common.Security;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
@@ -14,7 +13,6 @@ public sealed class GetCreatorProfileResponse
|
||||
public string Name { get; set; }
|
||||
public bool Verified { get; set; }
|
||||
public bool AcceptDonation { get; set; }
|
||||
public Colors Colors { get; set; }
|
||||
public Images Images { get; set; }
|
||||
public PresentationInfos PresentationInfos { get; set; }
|
||||
public Socials Socials { get; set; }
|
||||
@@ -48,7 +46,6 @@ public class GetCreatorProfileHandler(
|
||||
Name = c.Slugs.NormalizedName,
|
||||
Verified = c.Verified,
|
||||
AcceptDonation = c.AcceptDonation,
|
||||
Colors = c.Colors,
|
||||
Images = c.Images,
|
||||
PresentationInfos = c.PresentationInfos,
|
||||
Socials = c.Socials,
|
||||
|
||||
Reference in New Issue
Block a user