Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/LinkDotNet.Blog.Domain/BlogPostTemplate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;

namespace LinkDotNet.Blog.Domain;

public sealed class BlogPostTemplate : Entity
{
public string Name { get; private set; } = default!;

public string Title { get; private set; } = default!;

public string ShortDescription { get; private set; } = default!;

public string Content { get; private set; } = default!;

public static BlogPostTemplate Create(string name, string title, string shortDescription, string content)
{
return new BlogPostTemplate
{
Name = name,
Title = title,
ShortDescription = shortDescription,
Content = content
};
}
Comment on lines +15 to +24
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Create method lacks input validation. Based on the ShortCode entity pattern in this codebase (which includes ArgumentException.ThrowIfNullOrWhiteSpace for name validation), this method should validate that the name parameter is not null or whitespace before creating the entity. Without validation, invalid entities can be created and persisted to the database.

Copilot uses AI. Check for mistakes.

public void Update(string name, string title, string shortDescription, string content)
{
Name = name;
Title = title;
ShortDescription = shortDescription;
Content = content;
}
Comment on lines +26 to +32
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Update method lacks input validation. Following the pattern from ShortCode.Update in this codebase, this method should validate that the name parameter is not null or whitespace. Without validation, existing entities can be updated with invalid data.

Copilot uses AI. Check for mistakes.
}
Comment on lines +1 to +33
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test coverage for the BlogPostTemplate domain entity. Other domain entities in this codebase have corresponding unit tests (e.g., SkillTests.cs, TalkTests.cs, BlogPostTests.cs), but there are no tests for BlogPostTemplate's Create and Update methods. Tests should be added to verify the entity's behavior, especially if validation is added to these methods.

Copilot uses AI. Check for mistakes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace LinkDotNet.Blog.Web.Migrations;

/// <inheritdoc />
public partial class AddBlogPostTemplate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);

migrationBuilder.AlterColumn<string>(
name: "AuthorName",
table: "BlogPosts",
type: "TEXT",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(256)",
oldMaxLength: 256,
oldNullable: true);

migrationBuilder.CreateTable(
name: "BlogPostTemplates",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", unicode: false, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
Title = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
ShortDescription = table.Column<string>(type: "TEXT", nullable: false),
Content = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BlogPostTemplates", x => x.Id);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);

migrationBuilder.DropTable(
name: "BlogPostTemplates");

migrationBuilder.AlterColumn<string>(
name: "AuthorName",
table: "BlogPosts",
type: "TEXT",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(256)",
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Down migration incorrectly attempts to revert the AuthorName column type from TEXT back to nvarchar(256). However, based on the prior migration (20250830110439_AddAuthorNameInBlogPost.cs), the original type was nvarchar(256) which is SQL Server-specific, but this migration uses TEXT which is SQLite-specific. The Down method should revert to TEXT (not nvarchar) since the current database schema uses TEXT. This mismatch will cause the migration rollback to fail.

Suggested change
oldType: "nvarchar(256)",
oldType: "TEXT",

Copilot uses AI. Check for mistakes.
oldMaxLength: 256,
oldNullable: true);
}
}
Loading
Loading