diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/FileIdConverter.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/FileIdConverter.cs new file mode 100644 index 0000000..73b7f24 --- /dev/null +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/FileIdConverter.cs @@ -0,0 +1,9 @@ +using BuildingBlocks.Domain.ValueObjects.Ids; + +namespace BuildingBlocks.Api.Converters; + +public class FileIdConverter : IRegister +{ + public void Register(TypeAdapterConfig config) => + config.NewConfig().ConstructUsing(src => FileAssetId.Of(src.Value)); +} diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/NodeIdConverter.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/NodeIdConverter.cs new file mode 100644 index 0000000..2bf272f --- /dev/null +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/NodeIdConverter.cs @@ -0,0 +1,9 @@ +using BuildingBlocks.Domain.ValueObjects.Ids; + +namespace BuildingBlocks.Api.Converters; + +public class NodeIdConverter : IRegister +{ + public void Register(TypeAdapterConfig config) => + config.NewConfig().ConstructUsing(src => NodeId.Of(src.Value)); +} diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/NoteIdConverter.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/NoteIdConverter.cs new file mode 100644 index 0000000..8ae4c50 --- /dev/null +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/NoteIdConverter.cs @@ -0,0 +1,9 @@ +using BuildingBlocks.Domain.ValueObjects.Ids; + +namespace BuildingBlocks.Api.Converters; + +public class NoteIdConverter : IRegister +{ + public void Register(TypeAdapterConfig config) => + config.NewConfig().ConstructUsing(src => NoteId.Of(src.Value)); +} diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/ReminderIdConverter.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/ReminderIdConverter.cs new file mode 100644 index 0000000..0b1bb4b --- /dev/null +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/ReminderIdConverter.cs @@ -0,0 +1,9 @@ +using BuildingBlocks.Domain.ValueObjects.Ids; + +namespace BuildingBlocks.Api.Converters; + +public class ReminderIdConverter : IRegister +{ + public void Register(TypeAdapterConfig config) => + config.NewConfig().ConstructUsing(src => ReminderId.Of(src.Value)); +} diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/TimelineIdConverter.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/TimelineIdConverter.cs new file mode 100644 index 0000000..15fa426 --- /dev/null +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/TimelineIdConverter.cs @@ -0,0 +1,9 @@ +using BuildingBlocks.Domain.ValueObjects.Ids; + +namespace BuildingBlocks.Api.Converters; + +public class TimelineIdConverter : IRegister +{ + public void Register(TypeAdapterConfig config) => + config.NewConfig().ConstructUsing(src => TimelineId.Of(src.Value)); +} diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Api/GlobalUsing.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Api/GlobalUsing.cs new file mode 100644 index 0000000..766f651 --- /dev/null +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Api/GlobalUsing.cs @@ -0,0 +1 @@ +global using Mapster; diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/FileAssetId.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/FileAssetId.cs index 0411b72..c09da68 100644 --- a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/FileAssetId.cs +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/FileAssetId.cs @@ -1,13 +1,10 @@ -using System.Text.Json.Serialization; +namespace BuildingBlocks.Domain.ValueObjects.Ids; -namespace BuildingBlocks.Domain.ValueObjects.Ids; - -[JsonConverter(typeof(FileAssetIdJsonConverter))] -public record FileAssetId : StronglyTypedId +public class FileAssetId : StronglyTypedId { private FileAssetId(Guid value) : base(value) { } public static FileAssetId Of(Guid value) => new(value); - private class FileAssetIdJsonConverter : StronglyTypedIdJsonConverter; + public override string ToString() => Value.ToString(); } diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NodeId.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NodeId.cs index d026a7c..c259e08 100644 --- a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NodeId.cs +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NodeId.cs @@ -1,13 +1,10 @@ -using System.Text.Json.Serialization; +namespace BuildingBlocks.Domain.ValueObjects.Ids; -namespace BuildingBlocks.Domain.ValueObjects.Ids; - -[JsonConverter(typeof(NodeIdJsonConverter))] -public record NodeId : StronglyTypedId +public class NodeId : StronglyTypedId { private NodeId(Guid value) : base(value) { } public static NodeId Of(Guid value) => new(value); - - private class NodeIdJsonConverter : StronglyTypedIdJsonConverter; + + public override string ToString() => Value.ToString(); } diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NoteId.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NoteId.cs index 63436b0..b5c3dcc 100644 --- a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NoteId.cs +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NoteId.cs @@ -1,13 +1,10 @@ -using System.Text.Json.Serialization; +namespace BuildingBlocks.Domain.ValueObjects.Ids; -namespace BuildingBlocks.Domain.ValueObjects.Ids; - -[JsonConverter(typeof(NoteIdJsonConverter))] -public record NoteId : StronglyTypedId +public class NoteId : StronglyTypedId { private NoteId(Guid value) : base(value) { } public static NoteId Of(Guid value) => new(value); - - private class NoteIdJsonConverter : StronglyTypedIdJsonConverter; + + public override string ToString() => Value.ToString(); } diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/ReminderId.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/ReminderId.cs index 9e4195d..2080e6a 100644 --- a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/ReminderId.cs +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/ReminderId.cs @@ -1,13 +1,10 @@ -using System.Text.Json.Serialization; +namespace BuildingBlocks.Domain.ValueObjects.Ids; -namespace BuildingBlocks.Domain.ValueObjects.Ids; - -[JsonConverter(typeof(ReminderIdJsonConverter))] -public record ReminderId : StronglyTypedId +public class ReminderId : StronglyTypedId { private ReminderId(Guid value) : base(value) { } public static ReminderId Of(Guid value) => new(value); - private class ReminderIdJsonConverter : StronglyTypedIdJsonConverter; + public override string ToString() => Value.ToString(); } diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/TimelineId.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/TimelineId.cs index fee385e..cdad40d 100644 --- a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/TimelineId.cs +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/TimelineId.cs @@ -1,13 +1,10 @@ -using System.Text.Json.Serialization; +namespace BuildingBlocks.Domain.ValueObjects.Ids; -namespace BuildingBlocks.Domain.ValueObjects.Ids; - -[JsonConverter(typeof(TimelineIdJsonConverter))] -public record TimelineId : StronglyTypedId +public class TimelineId : StronglyTypedId { private TimelineId(Guid value) : base(value) { } public static TimelineId Of(Guid value) => new(value); - private class TimelineIdJsonConverter : StronglyTypedIdJsonConverter; + public override string ToString() => Value.ToString(); } diff --git a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/StronglyTypedId.cs b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/StronglyTypedId.cs index 41cec1b..b1e0750 100644 --- a/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/StronglyTypedId.cs +++ b/Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/StronglyTypedId.cs @@ -1,9 +1,6 @@ -using System.Text.Json.Serialization; -using System.Text.Json; +namespace BuildingBlocks.Domain.ValueObjects; -namespace BuildingBlocks.Domain.ValueObjects; - -public abstract record StronglyTypedId +public abstract class StronglyTypedId { protected StronglyTypedId(Guid value) { @@ -14,27 +11,6 @@ protected StronglyTypedId(Guid value) } public Guid Value { get; } - - public override string ToString() => Value.ToString(); -} - -public class StronglyTypedIdJsonConverter : JsonConverter where T : StronglyTypedId -{ - public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var value = reader.GetString(); - - if (Guid.TryParse(value, out var guid)) - { - var constructor = typeof(T).GetConstructor(new[] { typeof(Guid) }); - - if (constructor != null) - return (T)constructor.Invoke(new object[] { guid }); - } - - throw new JsonException($"Invalid GUID format for {typeof(T).Name}: {value}"); - } - - public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) => - writer.WriteStringValue(value.Value.ToString()); + + public abstract override string ToString(); } diff --git a/Backend/src/Modules/Files/Files.Api/Extensions/ServiceCollectionExtensions.cs b/Backend/src/Modules/Files/Files.Api/Extensions/ServiceCollectionExtensions.cs index 1632953..d2dd07a 100644 --- a/Backend/src/Modules/Files/Files.Api/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/src/Modules/Files/Files.Api/Extensions/ServiceCollectionExtensions.cs @@ -1,3 +1,4 @@ +using BuildingBlocks.Api.Converters; using Files.Application.Extensions; using Files.Infrastructure; using Microsoft.Extensions.Configuration; @@ -19,6 +20,8 @@ public static IServiceCollection AddFilesModule private static IServiceCollection AddApiServices(this IServiceCollection services) { + TypeAdapterConfig.GlobalSettings.Scan(typeof(FileIdConverter).Assembly); + return services; } diff --git a/Backend/src/Modules/Files/Files.Application/Extensions/ServiceCollectionExtensions.cs b/Backend/src/Modules/Files/Files.Application/Extensions/ServiceCollectionExtensions.cs index 3006850..986ee30 100644 --- a/Backend/src/Modules/Files/Files.Application/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/src/Modules/Files/Files.Application/Extensions/ServiceCollectionExtensions.cs @@ -15,6 +15,8 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection config.AddOpenBehavior(typeof(LoggingBehavior<,>)); }); + services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly()); + return services; } } diff --git a/Backend/src/Modules/Nodes/Nodes.Api/Extensions/ServiceCollectionExtensions.cs b/Backend/src/Modules/Nodes/Nodes.Api/Extensions/ServiceCollectionExtensions.cs index f9de648..6562ec0 100644 --- a/Backend/src/Modules/Nodes/Nodes.Api/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/src/Modules/Nodes/Nodes.Api/Extensions/ServiceCollectionExtensions.cs @@ -1,3 +1,4 @@ +using BuildingBlocks.Api.Converters; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Nodes.Application.Extensions; @@ -19,6 +20,8 @@ public static IServiceCollection AddNodesModule private static IServiceCollection AddApiServices(this IServiceCollection services) { + TypeAdapterConfig.GlobalSettings.Scan(typeof(NodeIdConverter).Assembly); + return services; } diff --git a/Backend/src/Modules/Nodes/Nodes.Application/Entities/Nodes/Commands/CreateNode/CreateNodeCommand.cs b/Backend/src/Modules/Nodes/Nodes.Application/Entities/Nodes/Commands/CreateNode/CreateNodeCommand.cs index 0fb812d..b0cfe33 100644 --- a/Backend/src/Modules/Nodes/Nodes.Application/Entities/Nodes/Commands/CreateNode/CreateNodeCommand.cs +++ b/Backend/src/Modules/Nodes/Nodes.Application/Entities/Nodes/Commands/CreateNode/CreateNodeCommand.cs @@ -15,11 +15,37 @@ public CreateNodeCommandValidator() RuleFor(x => x.Node.Title) .NotEmpty().WithMessage("Title is required.") .MaximumLength(100).WithMessage("Title must not exceed 100 characters."); - + RuleFor(x => x.Node.Description) .NotEmpty().WithMessage("Description is required.") .MaximumLength(500).WithMessage("Description must not exceed 500 characters."); - // ToDo: Add remaining Node command validators + RuleFor(x => x.Node.Timestamp) + .LessThanOrEqualTo(DateTime.Now).WithMessage("Timestamp cannot be in the future."); + + RuleFor(x => x.Node.Importance) + .InclusiveBetween(1, 10).WithMessage("Importance must be between 1 and 10."); + + RuleFor(x => x.Node.Phase) + .NotEmpty().WithMessage("Phase is required."); + + RuleFor(x => x.Node) + .NotNull().WithMessage("Node cannot be null.") + .DependentRules(() => + { + RuleFor(x => x.Node.Categories) + .Must(categories => categories != null && categories.Count > 0) + .WithMessage("At least one category must be provided."); + + RuleFor(x => x.Node.Tags) + .Must(tags => tags != null && tags.Count > 0) + .WithMessage("At least one tag must be provided."); + }); + + RuleForEach(x => x.Node.Categories) + .MaximumLength(50).WithMessage("Category must not exceed 50 characters."); + + RuleForEach(x => x.Node.Tags) + .MaximumLength(50).WithMessage("Tag must not exceed 50 characters."); } } diff --git a/Backend/src/Modules/Nodes/Nodes.Application/Extensions/ServiceCollectionExtensions.cs b/Backend/src/Modules/Nodes/Nodes.Application/Extensions/ServiceCollectionExtensions.cs index 91fddc5..28cafb1 100644 --- a/Backend/src/Modules/Nodes/Nodes.Application/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/src/Modules/Nodes/Nodes.Application/Extensions/ServiceCollectionExtensions.cs @@ -15,6 +15,8 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection config.AddOpenBehavior(typeof(LoggingBehavior<,>)); }); + services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly()); + return services; } } diff --git a/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Configurations/NodeConfiguration.cs b/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Configurations/NodeConfiguration.cs index 56efb78..69c8194 100644 --- a/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Configurations/NodeConfiguration.cs +++ b/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Configurations/NodeConfiguration.cs @@ -1,16 +1,28 @@ -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace Nodes.Infrastructure.Data.Configurations; - -public class NodeConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.HasKey(n => n.Id); - builder.Property(n => n.Id).HasConversion( - nodeId => nodeId.Value, - dbId => NodeId.Of(dbId)); - - // ToDo: Add remaining Node configuration commands - } -} +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Nodes.Infrastructure.Data.Configurations; + +public class NodeConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(n => n.Id); + builder.Property(n => n.Id).HasConversion( + nodeId => nodeId.Value, + dbId => NodeId.Of(dbId)); + + builder.Property(n => n.Title) + .IsRequired() + .HasMaxLength(100); + + builder.Property(n => n.Description) + .IsRequired() + .HasMaxLength(500); + + builder.Property(n => n.Importance) + .IsRequired(); + + builder.Property(n => n.Phase) + .IsRequired(); + } +} diff --git a/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Migrations/20241228182710_ApplyNewNodeConfigurations.Designer.cs b/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Migrations/20241228182710_ApplyNewNodeConfigurations.Designer.cs new file mode 100644 index 0000000..b127a32 --- /dev/null +++ b/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Migrations/20241228182710_ApplyNewNodeConfigurations.Designer.cs @@ -0,0 +1,73 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Nodes.Infrastructure.Data; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Nodes.Infrastructure.Data.Migrations +{ + [DbContext(typeof(NodesDbContext))] + [Migration("20241228182710_ApplyNewNodeConfigurations")] + partial class ApplyNewNodeConfigurations + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Nodes") + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Nodes.Domain.Models.Node", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Importance") + .HasColumnType("integer"); + + b.Property("LastModifiedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LastModifiedBy") + .HasColumnType("text"); + + b.Property("Phase") + .IsRequired() + .HasColumnType("text"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("Nodes", "Nodes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Migrations/20241228182710_ApplyNewNodeConfigurations.cs b/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Migrations/20241228182710_ApplyNewNodeConfigurations.cs new file mode 100644 index 0000000..8dc6259 --- /dev/null +++ b/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Migrations/20241228182710_ApplyNewNodeConfigurations.cs @@ -0,0 +1,58 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Nodes.Infrastructure.Data.Migrations +{ + /// + public partial class ApplyNewNodeConfigurations : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Title", + schema: "Nodes", + table: "Nodes", + type: "character varying(100)", + maxLength: 100, + nullable: false, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "Description", + schema: "Nodes", + table: "Nodes", + type: "character varying(500)", + maxLength: 500, + nullable: false, + oldClrType: typeof(string), + oldType: "text"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Title", + schema: "Nodes", + table: "Nodes", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(100)", + oldMaxLength: 100); + + migrationBuilder.AlterColumn( + name: "Description", + schema: "Nodes", + table: "Nodes", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(500)", + oldMaxLength: 500); + } + } +} diff --git a/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Migrations/NodesDbContextModelSnapshot.cs b/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Migrations/NodesDbContextModelSnapshot.cs index bfcc659..cd8b2de 100644 --- a/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Migrations/NodesDbContextModelSnapshot.cs +++ b/Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Migrations/NodesDbContextModelSnapshot.cs @@ -1,68 +1,70 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Nodes.Infrastructure.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Nodes.Infrastructure.Data.Migrations -{ - [DbContext(typeof(NodesDbContext))] - partial class NodesDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Nodes") - .HasAnnotation("ProductVersion", "9.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Nodes.Domain.Models.Node", b => - { - b.Property("Id") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("text"); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("Importance") - .HasColumnType("integer"); - - b.Property("LastModifiedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("LastModifiedBy") - .HasColumnType("text"); - - b.Property("Phase") - .IsRequired() - .HasColumnType("text"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Nodes", "Nodes"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Nodes.Infrastructure.Data; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Nodes.Infrastructure.Data.Migrations +{ + [DbContext(typeof(NodesDbContext))] + partial class NodesDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Nodes") + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Nodes.Domain.Models.Node", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Importance") + .HasColumnType("integer"); + + b.Property("LastModifiedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LastModifiedBy") + .HasColumnType("text"); + + b.Property("Phase") + .IsRequired() + .HasColumnType("text"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("Nodes", "Nodes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Backend/src/Modules/Notes/Notes.Api/Extensions/ServiceCollectionExtensions.cs b/Backend/src/Modules/Notes/Notes.Api/Extensions/ServiceCollectionExtensions.cs index 6b5f6d4..ac2cb93 100644 --- a/Backend/src/Modules/Notes/Notes.Api/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/src/Modules/Notes/Notes.Api/Extensions/ServiceCollectionExtensions.cs @@ -1,3 +1,4 @@ +using BuildingBlocks.Api.Converters; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Notes.Application.Extensions; @@ -19,6 +20,8 @@ public static IServiceCollection AddNotesModule private static IServiceCollection AddApiServices(this IServiceCollection services) { + TypeAdapterConfig.GlobalSettings.Scan(typeof(NoteIdConverter).Assembly); + return services; } diff --git a/Backend/src/Modules/Notes/Notes.Application/Extensions/ServiceCollectionExtensions.cs b/Backend/src/Modules/Notes/Notes.Application/Extensions/ServiceCollectionExtensions.cs index a3615b1..dcdef9d 100644 --- a/Backend/src/Modules/Notes/Notes.Application/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/src/Modules/Notes/Notes.Application/Extensions/ServiceCollectionExtensions.cs @@ -15,6 +15,8 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection config.AddOpenBehavior(typeof(LoggingBehavior<,>)); }); + services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly()); + return services; } } diff --git a/Backend/src/Modules/Reminders/Reminders.Api/Extensions/ServiceCollectionExtensions.cs b/Backend/src/Modules/Reminders/Reminders.Api/Extensions/ServiceCollectionExtensions.cs index ee2e3cd..8526d23 100644 --- a/Backend/src/Modules/Reminders/Reminders.Api/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/src/Modules/Reminders/Reminders.Api/Extensions/ServiceCollectionExtensions.cs @@ -1,3 +1,4 @@ +using BuildingBlocks.Api.Converters; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Reminders.Application.Extensions; @@ -19,6 +20,8 @@ public static IServiceCollection AddRemindersModule private static IServiceCollection AddApiServices(this IServiceCollection services) { + TypeAdapterConfig.GlobalSettings.Scan(typeof(ReminderIdConverter).Assembly); + return services; } diff --git a/Backend/src/Modules/Reminders/Reminders.Application/Extensions/ServiceCollectionExtensions.cs b/Backend/src/Modules/Reminders/Reminders.Application/Extensions/ServiceCollectionExtensions.cs index 2ecf10b..d0c9f15 100644 --- a/Backend/src/Modules/Reminders/Reminders.Application/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/src/Modules/Reminders/Reminders.Application/Extensions/ServiceCollectionExtensions.cs @@ -15,6 +15,8 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection config.AddOpenBehavior(typeof(LoggingBehavior<,>)); }); + services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly()); + return services; } } diff --git a/Backend/src/Modules/Timelines/Timelines.Api/Extensions/ServiceCollectionExtensions.cs b/Backend/src/Modules/Timelines/Timelines.Api/Extensions/ServiceCollectionExtensions.cs index f04ff3e..7158a4d 100644 --- a/Backend/src/Modules/Timelines/Timelines.Api/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/src/Modules/Timelines/Timelines.Api/Extensions/ServiceCollectionExtensions.cs @@ -1,3 +1,4 @@ +using BuildingBlocks.Api.Converters; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Timelines.Application.Extensions; @@ -19,6 +20,8 @@ public static IServiceCollection AddTimelinesModule private static IServiceCollection AddApiServices(this IServiceCollection services) { + TypeAdapterConfig.GlobalSettings.Scan(typeof(TimelineIdConverter).Assembly); + return services; } diff --git a/Backend/src/Modules/Timelines/Timelines.Application/Extensions/ServiceCollectionExtensions.cs b/Backend/src/Modules/Timelines/Timelines.Application/Extensions/ServiceCollectionExtensions.cs index 9ccc69d..55cfef7 100644 --- a/Backend/src/Modules/Timelines/Timelines.Application/Extensions/ServiceCollectionExtensions.cs +++ b/Backend/src/Modules/Timelines/Timelines.Application/Extensions/ServiceCollectionExtensions.cs @@ -15,6 +15,8 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection config.AddOpenBehavior(typeof(LoggingBehavior<,>)); }); + services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly()); + return services; } }