Finished DTO

This commit is contained in:
Cristiano
2025-10-17 09:13:23 +02:00
parent 3fa5289fb1
commit 2369cdbc39
170 changed files with 2539 additions and 53 deletions

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@romaric-thibault.fr" uuid="aacd8ac8-160e-4e0d-84d9-10cc1b66fb42">
<driver-ref>sqlserver.jb</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.jetbrains.jdbc.sqlserver.SqlServerDriver</jdbc-driver>
<jdbc-url>Server=romaric-thibault.fr,1433</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View File

@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIndexAttributeConvention_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fb3593391b65b2359cc317c643a63fe23ca4377ad8d04a967c89d8b1754847e3_003FIndexAttributeConvention_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIndexAttribute_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F37f743c0dfbad697acd27117a67cd6fad4e5bd2d3bc82eb1fad54ee8cce3538_003FIndexAttribute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

View File

@@ -15,17 +15,14 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.20" />
<PackageReference Include="Singulink.Cryptography.PasswordHasher" Version="3.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2"/>
</ItemGroup>
<ItemGroup>
<Folder Include="DTO\Comment\Request\" />
<Folder Include="DTO\Comment\Response\" />
<Folder Include="DTO\Post\Request\" />
<Folder Include="DTO\Post\Response\" />
<Folder Include="DTO\User\Request\" />
<Folder Include="DTO\User\Response\" />
<Folder Include="Endpoints\" />
<Folder Include="Endpoints\Comment\" />
<Folder Include="Endpoints\Post\" />
<Folder Include="Endpoints\User\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
namespace BlogPlatform.DTO.Comment.Request;
public class CreateCommentDto
{
public string? Content { get; set; }
public int PostId{ get; set; }
public int UserId { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace BlogPlatform.DTO.Comment.Request;
public class UpdateCommentDto
{
public int Id { get; set; }
public string? Content { get; set; }
public int PostId{ get; set; }
public int UserId { get; set; }
}

View File

@@ -0,0 +1,15 @@
namespace BlogPlatform.DTO.Comment.Response;
public class GetCommentDto
{
public int Id { get; set; }
public string? Content { get; set; }
//Flattening important data of association
public int PostId{ get; set; }
public string? PostTitle { get; set; }
public int UserId { get; set; }
public string? UserUsername { get; set; }
}

View File

@@ -0,0 +1,12 @@
using BlogPlatform.DTO.Comment.Response;
namespace BlogPlatform.DTO.Post.Request;
public class CreatePostDto
{
public string? Title { get; set; }
public string? Content { get; set; }
public int Likes { get; set; }
public int UserId { get; set; }
}

View File

@@ -0,0 +1,13 @@
using BlogPlatform.DTO.Comment.Response;
namespace BlogPlatform.DTO.Post.Request;
public class UpdatePostDto
{
public int Id { get; set; }
public string? Title { get; set; }
public string? Content { get; set; }
public int Likes { get; set; }
public int UserId { get; set; }
}

View File

@@ -0,0 +1,17 @@
using BlogPlatform.DTO.Comment.Response;
namespace BlogPlatform.DTO.Post.Response;
public class GetPostDto
{
public int Id { get; set; }
public string? Title { get; set; }
public string? Content { get; set; }
public int Likes { get; set; }
public List<GetCommentDto>? Comments { get; set; }
public int UserId { get; set; }
public string? UserUsername { get; set; }
public string? UserEmail { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BlogPlatform.DTO.User.Request;
public class ConnectUserDto
{
public string? Username { get; set; }
public string? Password { get; set; }
}

View File

@@ -0,0 +1,9 @@
namespace BlogPlatform.DTO.User.Request;
public class CreateUserDto
{
public string? Username { get; set; }
public string? Email { get; set; }
public string? Password { get; set; }
public string? Salt { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace BlogPlatform.DTO.User.Response;
public class GetUserDto
{
public int Id { get; set; }
public string? Username { get; set; }
public string? Email { get; set; }
public string? Password { get; set; }
public string? Salt { get; set; }
}

View File

@@ -0,0 +1,178 @@
// <auto-generated />
using System;
using BlogPlatform;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace BlogPlatform.Migrations
{
[DbContext(typeof(BlogPlatformDbContext))]
[Migration("20251017064347_InitialDatabase")]
partial class InitialDatabase
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.20")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("BlogPlatform.Models.Comment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateOnly>("CreatedAt")
.ValueGeneratedOnAdd()
.HasColumnType("date")
.HasDefaultValueSql("getdate()");
b.Property<int>("PostId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PostId");
b.HasIndex("UserId");
b.ToTable("Comments");
});
modelBuilder.Entity("BlogPlatform.Models.Post", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateOnly>("CreatedAt")
.ValueGeneratedOnAdd()
.HasColumnType("date")
.HasDefaultValueSql("getdate()");
b.Property<int>("Likes")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Posts");
});
modelBuilder.Entity("BlogPlatform.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateOnly>("CreatedAt")
.ValueGeneratedOnAdd()
.HasColumnType("date")
.HasDefaultValueSql("getdate()");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Salt")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique();
b.HasIndex("Username")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("BlogPlatform.Models.Comment", b =>
{
b.HasOne("BlogPlatform.Models.Post", "Post")
.WithMany("Comments")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BlogPlatform.Models.User", "User")
.WithMany("Comments")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.Navigation("Post");
b.Navigation("User");
});
modelBuilder.Entity("BlogPlatform.Models.Post", b =>
{
b.HasOne("BlogPlatform.Models.User", "User")
.WithMany("Posts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("BlogPlatform.Models.Post", b =>
{
b.Navigation("Comments");
});
modelBuilder.Entity("BlogPlatform.Models.User", b =>
{
b.Navigation("Comments");
b.Navigation("Posts");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,122 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BlogPlatform.Migrations
{
/// <inheritdoc />
public partial class InitialDatabase : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Username = table.Column<string>(type: "nvarchar(450)", nullable: false),
Email = table.Column<string>(type: "nvarchar(450)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
Salt = table.Column<string>(type: "nvarchar(max)", nullable: false),
CreatedAt = table.Column<DateOnly>(type: "date", nullable: false, defaultValueSql: "getdate()")
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Posts",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
Likes = table.Column<int>(type: "int", nullable: false),
CreatedAt = table.Column<DateOnly>(type: "date", nullable: false, defaultValueSql: "getdate()"),
UserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Posts", x => x.Id);
table.ForeignKey(
name: "FK_Posts_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Comments",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
CreatedAt = table.Column<DateOnly>(type: "date", nullable: false, defaultValueSql: "getdate()"),
PostId = table.Column<int>(type: "int", nullable: false),
UserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Comments", x => x.Id);
table.ForeignKey(
name: "FK_Comments_Posts_PostId",
column: x => x.PostId,
principalTable: "Posts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Comments_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Comments_PostId",
table: "Comments",
column: "PostId");
migrationBuilder.CreateIndex(
name: "IX_Comments_UserId",
table: "Comments",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Posts_UserId",
table: "Posts",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Users_Email",
table: "Users",
column: "Email",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Users_Username",
table: "Users",
column: "Username",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Comments");
migrationBuilder.DropTable(
name: "Posts");
migrationBuilder.DropTable(
name: "Users");
}
}
}

View File

@@ -0,0 +1,175 @@
// <auto-generated />
using System;
using BlogPlatform;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace BlogPlatform.Migrations
{
[DbContext(typeof(BlogPlatformDbContext))]
partial class BlogPlatformDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.20")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("BlogPlatform.Models.Comment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateOnly>("CreatedAt")
.ValueGeneratedOnAdd()
.HasColumnType("date")
.HasDefaultValueSql("getdate()");
b.Property<int>("PostId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PostId");
b.HasIndex("UserId");
b.ToTable("Comments");
});
modelBuilder.Entity("BlogPlatform.Models.Post", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateOnly>("CreatedAt")
.ValueGeneratedOnAdd()
.HasColumnType("date")
.HasDefaultValueSql("getdate()");
b.Property<int>("Likes")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Posts");
});
modelBuilder.Entity("BlogPlatform.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateOnly>("CreatedAt")
.ValueGeneratedOnAdd()
.HasColumnType("date")
.HasDefaultValueSql("getdate()");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Salt")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique();
b.HasIndex("Username")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("BlogPlatform.Models.Comment", b =>
{
b.HasOne("BlogPlatform.Models.Post", "Post")
.WithMany("Comments")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BlogPlatform.Models.User", "User")
.WithMany("Comments")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.Navigation("Post");
b.Navigation("User");
});
modelBuilder.Entity("BlogPlatform.Models.Post", b =>
{
b.HasOne("BlogPlatform.Models.User", "User")
.WithMany("Posts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("BlogPlatform.Models.Post", b =>
{
b.Navigation("Comments");
});
modelBuilder.Entity("BlogPlatform.Models.User", b =>
{
b.Navigation("Comments");
b.Navigation("Posts");
});
#pragma warning restore 612, 618
}
}
}

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "8.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Reflection.NullabilityInfoContext.IsSupported": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

Some files were not shown because too many files have changed in this diff Show More