diff --git a/DatabaseModels/DataTransferObjets/ScoreboardRecordDto.cs b/DatabaseModels/DataTransferObjets/ScoreboardRecordDto.cs
new file mode 100644
index 0000000..2fdaece
--- /dev/null
+++ b/DatabaseModels/DataTransferObjets/ScoreboardRecordDto.cs
@@ -0,0 +1,11 @@
+namespace DatabaseModels.DataTransferObjets;
+
+public class ScoreboardRecordDto
+{
+ public int Id { get; set; }
+
+ public int Score { get; set; }
+ public DateTime PostTime { get; set; }
+
+ public UserDto User { get; set; } = null!;
+}
\ No newline at end of file
diff --git a/DatabaseModels/DataTransferObjets/UserDto.cs b/DatabaseModels/DataTransferObjets/UserDto.cs
new file mode 100644
index 0000000..cee32da
--- /dev/null
+++ b/DatabaseModels/DataTransferObjets/UserDto.cs
@@ -0,0 +1,8 @@
+namespace DatabaseModels.DataTransferObjets;
+
+public class UserDto
+{
+ public int Id { get; set; }
+
+ public string Username { get; set; } = null!;
+}
\ No newline at end of file
diff --git a/DatabaseModels/DatabaseModels.csproj b/DatabaseModels/DatabaseModels.csproj
index 2437130..eb2460e 100644
--- a/DatabaseModels/DatabaseModels.csproj
+++ b/DatabaseModels/DatabaseModels.csproj
@@ -6,8 +6,4 @@
enable
-
-
-
-
diff --git a/DatabaseModels/InitialObjects/ScoreboardRecord.cs b/DatabaseModels/InitialObjects/ScoreboardRecord.cs
new file mode 100644
index 0000000..cab08f0
--- /dev/null
+++ b/DatabaseModels/InitialObjects/ScoreboardRecord.cs
@@ -0,0 +1,15 @@
+using DatabaseModels.DataTransferObjets;
+
+namespace DatabaseModels.InitialObjects;
+
+public class ScoreboardRecord
+{
+ public int Id { get; set; }
+
+ public int Score { get; set; }
+ public DateTime PostTime { get; set; }
+
+ public User User { get; set; } = null!;
+
+ public ScoreboardRecordDto ToDto() => new() { Id = Id, Score = Score, PostTime = PostTime, User = User.ToDto() };
+}
\ No newline at end of file
diff --git a/DatabaseModels/Plain/User.cs b/DatabaseModels/InitialObjects/User.cs
similarity index 59%
rename from DatabaseModels/Plain/User.cs
rename to DatabaseModels/InitialObjects/User.cs
index 49a1f6e..6902680 100644
--- a/DatabaseModels/Plain/User.cs
+++ b/DatabaseModels/InitialObjects/User.cs
@@ -1,4 +1,6 @@
-namespace DatabaseModels.Plain;
+using DatabaseModels.DataTransferObjets;
+
+namespace DatabaseModels.InitialObjects;
public class User
{
@@ -7,6 +9,10 @@ public class User
public string Username { get; set; } = null!;
public string PasswordHash { get; set; } = null!;
public string PasswordSalt { get; set; } = null!;
+
+ public string Role { get; set; } = null!;
public ICollection ScoreboardRecords { get; set; } = null!;
+
+ public UserDto ToDto() => new() { Id = Id, Username = Username };
}
\ No newline at end of file
diff --git a/DatabaseModels/Plain/ScoreboardRecord.cs b/DatabaseModels/Plain/ScoreboardRecord.cs
deleted file mode 100644
index 965c379..0000000
--- a/DatabaseModels/Plain/ScoreboardRecord.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace DatabaseModels.Plain;
-
-public class ScoreboardRecord
-{
- public int Id { get; set; }
-
- public int Score { get; set; }
- public DateTime PostTime { get; set; }
-
- public User User { get; set; }
-}
\ No newline at end of file
diff --git a/Server/Migrations/20220717101814_AddUserRole.Designer.cs b/Server/Migrations/20220717101814_AddUserRole.Designer.cs
new file mode 100644
index 0000000..c22698f
--- /dev/null
+++ b/Server/Migrations/20220717101814_AddUserRole.Designer.cs
@@ -0,0 +1,89 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Server.Data;
+
+#nullable disable
+
+namespace Server.Migrations
+{
+ [DbContext(typeof(ServerDbContext))]
+ [Migration("20220717101814_AddUserRole")]
+ partial class AddUserRole
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "6.0.6");
+
+ modelBuilder.Entity("DatabaseModels.Plain.ScoreboardRecord", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("PostTime")
+ .HasColumnType("TEXT");
+
+ b.Property("Score")
+ .HasColumnType("INTEGER");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Scoreboard");
+ });
+
+ modelBuilder.Entity("DatabaseModels.Plain.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("PasswordHash")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("PasswordSalt")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Role")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Username")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Users");
+ });
+
+ modelBuilder.Entity("DatabaseModels.Plain.ScoreboardRecord", b =>
+ {
+ b.HasOne("DatabaseModels.Plain.User", "User")
+ .WithMany("ScoreboardRecords")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("DatabaseModels.Plain.User", b =>
+ {
+ b.Navigation("ScoreboardRecords");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Server/Migrations/20220717101814_AddUserRole.cs b/Server/Migrations/20220717101814_AddUserRole.cs
new file mode 100644
index 0000000..91c00d5
--- /dev/null
+++ b/Server/Migrations/20220717101814_AddUserRole.cs
@@ -0,0 +1,26 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace Server.Migrations
+{
+ public partial class AddUserRole : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "Role",
+ table: "Users",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: "");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Role",
+ table: "Users");
+ }
+ }
+}
diff --git a/Server/Migrations/ServerDbContextModelSnapshot.cs b/Server/Migrations/ServerDbContextModelSnapshot.cs
index 6a38932..b6a23ae 100644
--- a/Server/Migrations/ServerDbContextModelSnapshot.cs
+++ b/Server/Migrations/ServerDbContextModelSnapshot.cs
@@ -53,6 +53,10 @@ namespace Server.Migrations
.IsRequired()
.HasColumnType("TEXT");
+ b.Property("Role")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
b.Property("Username")
.IsRequired()
.HasColumnType("TEXT");