Mostly backend models stuff

Changed some models, did some work on database, created a class diagram.
This commit is contained in:
Nadegamra
2021-09-08 20:20:32 +03:00
parent 3e82ea9392
commit a3b4bb2e30
11 changed files with 105 additions and 14 deletions

View File

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

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="KTUSAPS.Data.Model.Issue">
<Position X="0.75" Y="1.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAACAAJAACAgAAAAAAACAAgIAAEAAAQAAAAAAAAAAAA=</HashCode>
<FileName>Model\Issue.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="Feedback" />
<Property Name="Problem" />
</ShowAsAssociation>
</Class>
<Class Name="KTUSAPS.Data.Model.PublishedFeedback">
<Position X="3.75" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAECAAAAAAAAAAAACAIAAAAAAAAAAAQAEAAAAAAAAAA=</HashCode>
<FileName>Model\PublishedFeedback.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="Issue" />
</ShowAsAssociation>
</Class>
<Class Name="KTUSAPS.Data.Model.PublishedProblem">
<Position X="3.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>ACECABAAAAEAAAgAAAABAAAAEAAAQAQAEAAAAAAAAAA=</HashCode>
<FileName>Model\PublishedProblem.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="Solution" />
<Property Name="Issue" />
</ShowAsAssociation>
<ShowAsCollectionAssociation>
<Property Name="Votes" />
</ShowAsCollectionAssociation>
</Class>
<Class Name="KTUSAPS.Data.Model.Solution">
<Position X="6.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAACAAIABAAAAQAAAAAAAAAAAAAAAAQAAAAAAAAAAAA=</HashCode>
<FileName>Model\Solution.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="Problem" />
</ShowAsAssociation>
</Class>
<Class Name="KTUSAPS.Data.Model.Vote">
<Position X="6.5" Y="2.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAIAAAAAEAAAAAAAAAgAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Model\Vote.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="Problem" />
</ShowAsAssociation>
</Class>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -9,8 +10,10 @@ namespace KTUSAPS.Data.Model
{
public class Issue
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[MaxLength(64)]
public string UserID { get; set; }
public string Email { get; set; }
public bool Anonimous { get; set; }
public bool Publishable { get; set; }
@@ -20,5 +23,6 @@ namespace KTUSAPS.Data.Model
public string Description { get; set; }
public PublishedProblem Problem { get; set; }
public PublishedFeedback Feedback { get; set; }
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -9,6 +10,7 @@ namespace KTUSAPS.Data.Model
{
public class PublishedFeedback
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
[MaxLength]

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -9,6 +10,7 @@ namespace KTUSAPS.Data.Model
{
public class PublishedProblem
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
[MaxLength]
@@ -28,5 +30,8 @@ namespace KTUSAPS.Data.Model
public int? SolutionId { get; set; }
public Solution Solution { get; set; }
public ICollection<Vote> Votes { get; set; }
}
}

View File

@@ -1,10 +1,12 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace KTUSAPS.Data.Model
{
public class Solution
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[MaxLength]
public string SolutionLt { get; set; }

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KTUSAPS.Data.Model
{
public class Vote
{
[MaxLength(64)]
public string UserId { get; set; }
public int ProblemId { get; set; }
public PublishedProblem Problem { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using KTUSAPS.Data.Model;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -13,7 +14,8 @@ namespace KTUSAPS.Data
public SAPSDataContext(DbContextOptions options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Vote>()
.HasKey(v => new { v.UserId, v.ProblemId });
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
@@ -24,6 +26,11 @@ namespace KTUSAPS.Data
}
}
public DbSet<Issue> Issues { get; set; }
public DbSet<PublishedFeedback> PublishedFeedbacks { get; set; }
public DbSet<PublishedProblem> PublishedProblems { get; set; }
public DbSet<Solution> Solutions { get; set; }
public DbSet<Vote> Votes { get; set; }
}
}