add user database links

This commit is contained in:
MaxKarme 2023-04-09 00:45:19 +04:00
parent cc04070287
commit 48db39218d
4 changed files with 22 additions and 0 deletions

View File

@ -17,6 +17,8 @@ namespace UniversityDatabaseImplement.Models
public virtual List<StatementStudent> StatementStudents { get; set; } = new();
[ForeignKey("StudentId")]
public virtual List<StudentExaminationResult> StudentExaminationResults { get; set; } = new();
[ForeignKey("StudentId")]
public virtual List<UserStudent> StudentUsers { get; set; } = new();
private Dictionary<int, IStatementModel>? _statements;
[NotMapped]

View File

@ -21,6 +21,10 @@ namespace UniversityDatabaseImplement.Models
public string Login { get; set; } = string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
[ForeignKey("UserId")]
public virtual List<UserStudent> StudentUsers { get; set; } = new();
[ForeignKey("UserId")]
public virtual List<Statement> Statements { get; set; } = new();
public static User Create(UserBindingModel model)
{
return new User

View File

@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;
namespace UniversityDatabaseImplement.Models
{
public class UserStudent
{
public int Id { get; set; }
[Required]
public int StudentTypeId { get; set; }
[Required]
public int UserId { get; set; }
public virtual Student Student { get; set; } = new();
public virtual User User { get; set; } = new();
}
}

View File

@ -24,5 +24,6 @@ namespace UniversityDatabaseImplement
public virtual DbSet<Student> Students { set; get; }
public virtual DbSet<StudentExaminationResult> StudentExaminationResults { set; get; }
public virtual DbSet<User> Users { set; get; }
public virtual DbSet<UserStudent> UserStudents { set; get; }
}
}