Huge work

This commit is contained in:
Karolis Kundrotas
2021-10-25 22:00:01 +03:00
parent c3bb8983ef
commit aff6f8df82
26 changed files with 578 additions and 68 deletions

View File

@@ -14,4 +14,8 @@
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>

View File

@@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace KTUSAPS.Data.Migrations
{
[DbContext(typeof(SAPSDataContext))]
[Migration("20210909173149_Initial")]
[Migration("20211015122630_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -50,6 +50,9 @@ namespace KTUSAPS.Data.Migrations
.HasMaxLength(320)
.HasColumnType("varchar(320)");
b.Property<int>("IssueTypeId")
.HasColumnType("int");
b.Property<bool>("Publishable")
.HasColumnType("tinyint(1)");
@@ -62,9 +65,28 @@ namespace KTUSAPS.Data.Migrations
b.HasKey("Id");
b.HasIndex("IssueTypeId");
b.ToTable("Issues");
});
modelBuilder.Entity("KTUSAPS.Data.Model.IssueType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("longtext");
b.Property<string>("NameEn")
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("IssueTypes");
});
modelBuilder.Entity("KTUSAPS.Data.Model.PublishedFeedback", b =>
{
b.Property<int>("Id")
@@ -169,6 +191,17 @@ namespace KTUSAPS.Data.Migrations
b.ToTable("Votes");
});
modelBuilder.Entity("KTUSAPS.Data.Model.Issue", b =>
{
b.HasOne("KTUSAPS.Data.Model.IssueType", "IssueType")
.WithMany("Issues")
.HasForeignKey("IssueTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("IssueType");
});
modelBuilder.Entity("KTUSAPS.Data.Model.PublishedFeedback", b =>
{
b.HasOne("KTUSAPS.Data.Model.Issue", "Issue")
@@ -211,6 +244,11 @@ namespace KTUSAPS.Data.Migrations
b.Navigation("Problem");
});
modelBuilder.Entity("KTUSAPS.Data.Model.IssueType", b =>
{
b.Navigation("Issues");
});
modelBuilder.Entity("KTUSAPS.Data.Model.PublishedProblem", b =>
{
b.Navigation("Votes");

View File

@@ -27,24 +27,19 @@ namespace KTUSAPS.Data.Migrations
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Issues",
name: "IssueTypes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserID = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true)
Name = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Email = table.Column<string>(type: "varchar(320)", maxLength: 320, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Publishable = table.Column<bool>(type: "tinyint(1)", nullable: false),
Solved = table.Column<bool>(type: "tinyint(1)", nullable: false),
Created = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Description = table.Column<string>(type: "longtext", nullable: true)
NameEn = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Issues", x => x.Id);
table.PrimaryKey("PK_IssueTypes", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
@@ -66,6 +61,35 @@ namespace KTUSAPS.Data.Migrations
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Issues",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserID = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Email = table.Column<string>(type: "varchar(320)", maxLength: 320, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Publishable = table.Column<bool>(type: "tinyint(1)", nullable: false),
Solved = table.Column<bool>(type: "tinyint(1)", nullable: false),
Created = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Description = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
IssueTypeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Issues", x => x.Id);
table.ForeignKey(
name: "FK_Issues_IssueTypes_IssueTypeId",
column: x => x.IssueTypeId,
principalTable: "IssueTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "PublishedFeedbacks",
columns: table => new
@@ -147,6 +171,11 @@ namespace KTUSAPS.Data.Migrations
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_Issues_IssueTypeId",
table: "Issues",
column: "IssueTypeId");
migrationBuilder.CreateIndex(
name: "IX_PublishedFeedbacks_IssueId",
table: "PublishedFeedbacks",
@@ -190,6 +219,9 @@ namespace KTUSAPS.Data.Migrations
migrationBuilder.DropTable(
name: "Solutions");
migrationBuilder.DropTable(
name: "IssueTypes");
}
}
}

View File

@@ -48,6 +48,9 @@ namespace KTUSAPS.Data.Migrations
.HasMaxLength(320)
.HasColumnType("varchar(320)");
b.Property<int>("IssueTypeId")
.HasColumnType("int");
b.Property<bool>("Publishable")
.HasColumnType("tinyint(1)");
@@ -60,9 +63,28 @@ namespace KTUSAPS.Data.Migrations
b.HasKey("Id");
b.HasIndex("IssueTypeId");
b.ToTable("Issues");
});
modelBuilder.Entity("KTUSAPS.Data.Model.IssueType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("longtext");
b.Property<string>("NameEn")
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("IssueTypes");
});
modelBuilder.Entity("KTUSAPS.Data.Model.PublishedFeedback", b =>
{
b.Property<int>("Id")
@@ -167,6 +189,17 @@ namespace KTUSAPS.Data.Migrations
b.ToTable("Votes");
});
modelBuilder.Entity("KTUSAPS.Data.Model.Issue", b =>
{
b.HasOne("KTUSAPS.Data.Model.IssueType", "IssueType")
.WithMany("Issues")
.HasForeignKey("IssueTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("IssueType");
});
modelBuilder.Entity("KTUSAPS.Data.Model.PublishedFeedback", b =>
{
b.HasOne("KTUSAPS.Data.Model.Issue", "Issue")
@@ -209,6 +242,11 @@ namespace KTUSAPS.Data.Migrations
b.Navigation("Problem");
});
modelBuilder.Entity("KTUSAPS.Data.Model.IssueType", b =>
{
b.Navigation("Issues");
});
modelBuilder.Entity("KTUSAPS.Data.Model.PublishedProblem", b =>
{
b.Navigation("Votes");

View File

@@ -22,7 +22,15 @@ namespace KTUSAPS.Data.Model
[MaxLength]
public string Description { get; set; }
public PublishedProblem Problem { get; set; }
public PublishedFeedback Feedback { get; set; }
public int IssueTypeId { get; set; }
public virtual IssueType IssueType { get; set; }
public virtual PublishedProblem Problem { get; set; }
public virtual PublishedFeedback Feedback { get; set; }
public Issue()
{
Created = DateTime.Now;
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KTUSAPS.Data.Model
{
public class IssueType
{
public int Id { get; set; }
public string Name { get; set; }
public string NameEn { get; set; }
public virtual ICollection<Issue> Issues { get; set; }
}
}

View File

@@ -1,18 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="KTUSAPS.Data.Model.Issue">
<Position X="0.5" Y="0.75" Width="1.5" />
<Position X="10.25" Y="1" Width="1.5" />
<TypeIdentifier>
<HashCode>AAACAAJAACAgAAAAAAACAAgIAAAAAAQAAAAAAAAAAAA=</HashCode>
<HashCode>AIACAAJQACAgAAAAAAACAAgIAAAAAAQAAAAAAAAAAAA=</HashCode>
<FileName>Model\Issue.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="Problem" />
<Property Name="Feedback" />
<Property Name="IssueType" />
</ShowAsAssociation>
</Class>
<Class Name="KTUSAPS.Data.Model.PublishedFeedback">
<Position X="2.75" Y="3.75" Width="1.5" />
<Position X="6.5" Y="3" Width="1.5" />
<TypeIdentifier>
<HashCode>AAECAAAAAAAAAAAACAIAAAAAAAAAAAQAEAAAAAAAAAA=</HashCode>
<FileName>Model\PublishedFeedback.cs</FileName>
@@ -22,9 +23,9 @@
</ShowAsAssociation>
</Class>
<Class Name="KTUSAPS.Data.Model.PublishedProblem">
<Position X="2.75" Y="0.75" Width="1.5" />
<Position X="4" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>ACECABAAAAEAAAgAAAABAAAAEAAAQAQAEAAAAAAAAAA=</HashCode>
<HashCode>ACECABAAAAEAAAgAAAABAAAAAAAAAAQAEAAAAAAAAAA=</HashCode>
<FileName>Model\PublishedProblem.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
@@ -36,7 +37,7 @@
</ShowAsCollectionAssociation>
</Class>
<Class Name="KTUSAPS.Data.Model.Solution">
<Position X="6" Y="0.5" Width="1.5" />
<Position X="0.75" Y="0.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAACAAIABAAAAQAAAAAAAAAAAAAAAAQAAAAAAAAAAAA=</HashCode>
<FileName>Model\Solution.cs</FileName>
@@ -46,7 +47,7 @@
</ShowAsAssociation>
</Class>
<Class Name="KTUSAPS.Data.Model.Vote">
<Position X="6" Y="2.5" Width="1.5" />
<Position X="3.5" Y="4.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAIAAAAAEAAAAAAAAAgAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Model\Vote.cs</FileName>
@@ -55,5 +56,15 @@
<Property Name="Problem" />
</ShowAsAssociation>
</Class>
<Class Name="KTUSAPS.Data.Model.IssueType">
<Position X="12.25" Y="5.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAECAAAAAAAAAAAAACAAAAQAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Model\IssueType.cs</FileName>
</TypeIdentifier>
<ShowAsCollectionAssociation>
<Property Name="Issues" />
</ShowAsCollectionAssociation>
</Class>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -22,6 +22,11 @@ namespace KTUSAPS.Data.Model
public DateTime Created { get; set; }
public int? IssueId { get; set; }
public Issue Issue { get; set; }
public virtual Issue Issue { get; set; }
public PublishedFeedback()
{
Created = DateTime.Now;
}
}
}

View File

@@ -18,20 +18,19 @@ namespace KTUSAPS.Data.Model
[Required]
[MaxLength]
public string ProblemEn { get; set; }
[MaxLength]
public string ResponseLt { get; set; }
[MaxLength]
public string ResponseEn { get; set; }
public DateTime Created { get; set; }
public int? IssueId { get; set; }
public Issue Issue { get; set; }
public virtual Issue Issue { get; set; }
public int? SolutionId { get; set; }
public Solution Solution { get; set; }
public virtual Solution Solution { get; set; }
public ICollection<Vote> Votes { get; set; }
public PublishedProblem()
{
Created = DateTime.Now;
}
}
}

View File

@@ -14,7 +14,12 @@ namespace KTUSAPS.Data.Model
public string SolutionEn { get; set; }
public PublishedProblem Problem { get; set; }
public DateTime Created { get; set; }
public virtual PublishedProblem Problem { get; set; }
public DateTime Created { get; set; }
public Solution()
{
Created = DateTime.Now;
}
}
}

View File

@@ -12,7 +12,7 @@ namespace KTUSAPS.Data.Model
[MaxLength(64)]
public string UserId { get; set; }
public int ProblemId { get; set; }
public PublishedProblem Problem { get; set; }
public virtual PublishedProblem Problem { get; set; }
}
}

View File

@@ -26,6 +26,7 @@ namespace KTUSAPS.Data
}
}
public DbSet<IssueType> IssueTypes { get; set; }
public DbSet<Issue> Issues { get; set; }
public DbSet<PublishedFeedback> PublishedFeedbacks { get; set; }
public DbSet<PublishedProblem> PublishedProblems { get; set; }