Skip to content

Commit a1936cb

Browse files
committed
feat: Added templates for blog post editor
1 parent 646a529 commit a1936cb

File tree

11 files changed

+792
-6
lines changed

11 files changed

+792
-6
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
3+
namespace LinkDotNet.Blog.Domain;
4+
5+
public sealed class BlogPostTemplate : Entity
6+
{
7+
public string Name { get; private set; } = default!;
8+
9+
public string Title { get; private set; } = default!;
10+
11+
public string ShortDescription { get; private set; } = default!;
12+
13+
public string Content { get; private set; } = default!;
14+
15+
public static BlogPostTemplate Create(string name, string title, string shortDescription, string content)
16+
{
17+
return new BlogPostTemplate
18+
{
19+
Name = name,
20+
Title = title,
21+
ShortDescription = shortDescription,
22+
Content = content
23+
};
24+
}
25+
26+
public void Update(string name, string title, string shortDescription, string content)
27+
{
28+
Name = name;
29+
Title = title;
30+
ShortDescription = shortDescription;
31+
Content = content;
32+
}
33+
}

src/LinkDotNet.Blog.Infrastructure/Migrations/20260109211327_AddBlogPostTemplate.Designer.cs

Lines changed: 277 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using System;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
4+
#nullable disable
5+
6+
namespace LinkDotNet.Blog.Web.Migrations;
7+
8+
/// <inheritdoc />
9+
public partial class AddBlogPostTemplate : Migration
10+
{
11+
/// <inheritdoc />
12+
protected override void Up(MigrationBuilder migrationBuilder)
13+
{
14+
ArgumentNullException.ThrowIfNull(migrationBuilder);
15+
16+
migrationBuilder.AlterColumn<string>(
17+
name: "AuthorName",
18+
table: "BlogPosts",
19+
type: "TEXT",
20+
maxLength: 256,
21+
nullable: true,
22+
oldClrType: typeof(string),
23+
oldType: "nvarchar(256)",
24+
oldMaxLength: 256,
25+
oldNullable: true);
26+
27+
migrationBuilder.CreateTable(
28+
name: "BlogPostTemplates",
29+
columns: table => new
30+
{
31+
Id = table.Column<string>(type: "TEXT", unicode: false, nullable: false),
32+
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
33+
Title = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
34+
ShortDescription = table.Column<string>(type: "TEXT", nullable: false),
35+
Content = table.Column<string>(type: "TEXT", nullable: false)
36+
},
37+
constraints: table =>
38+
{
39+
table.PrimaryKey("PK_BlogPostTemplates", x => x.Id);
40+
});
41+
}
42+
43+
/// <inheritdoc />
44+
protected override void Down(MigrationBuilder migrationBuilder)
45+
{
46+
ArgumentNullException.ThrowIfNull(migrationBuilder);
47+
48+
migrationBuilder.DropTable(
49+
name: "BlogPostTemplates");
50+
51+
migrationBuilder.AlterColumn<string>(
52+
name: "AuthorName",
53+
table: "BlogPosts",
54+
type: "TEXT",
55+
maxLength: 256,
56+
nullable: true,
57+
oldClrType: typeof(string),
58+
oldType: "nvarchar(256)",
59+
oldMaxLength: 256,
60+
oldNullable: true);
61+
}
62+
}

0 commit comments

Comments
 (0)