Adds Database Structure in C# with Entity Framework
This commit is contained in:
32
WatchLog/Data/Database/Private/Label.cs
Normal file
32
WatchLog/Data/Database/Private/Label.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
public class Label
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
public required DateTime CreationTime { get; set; }
|
||||
|
||||
public DateTime? LastChange { get; set; }
|
||||
|
||||
|
||||
// --- Foreign Key ---
|
||||
[Required]
|
||||
public int CreatorId { get; set; }
|
||||
|
||||
|
||||
// --- Navigation Properties ---
|
||||
[ForeignKey(nameof(CreatorId))]
|
||||
public virtual User User { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<LinkTablePrivateLabel> LinkTablePrivateLabels { get; set; } = new List<LinkTablePrivateLabel>();
|
||||
}
|
||||
}
|
||||
21
WatchLog/Data/Database/Private/LinkTablePrivateLabel.cs
Normal file
21
WatchLog/Data/Database/Private/LinkTablePrivateLabel.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
[PrimaryKey(nameof(PrivateEntityId), nameof(LabelId))]
|
||||
public class LinkTablePrivateLabel
|
||||
{
|
||||
// --- Foreign Keys ---
|
||||
public int PrivateEntityId { get; set; }
|
||||
public int LabelId { get; set; }
|
||||
|
||||
|
||||
// --- Navigation Properties ---
|
||||
[ForeignKey(nameof(PrivateEntityId))]
|
||||
public virtual PrivateEntity PrivateEntity { get; set; } = null!;
|
||||
|
||||
[ForeignKey(nameof(LabelId))]
|
||||
public virtual Label Label { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
[PrimaryKey(nameof(PrivateEntityId), nameof(StreamingPlatformId))]
|
||||
public class LinkTablePrivateStreamingPlatform
|
||||
{
|
||||
// --- Foreign Keys ---
|
||||
public int PrivateEntityId { get; set; }
|
||||
public int StreamingPlatformId { get; set; }
|
||||
|
||||
|
||||
// --- Navigation Properties ---
|
||||
[ForeignKey(nameof(PrivateEntityId))]
|
||||
public virtual PrivateEntity PrivateEntity { get; set; } = null!;
|
||||
|
||||
[ForeignKey(nameof(StreamingPlatformId))]
|
||||
public virtual StreamingPlatform StreamingPlatform { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
52
WatchLog/Data/Database/Private/PrivateEntity.cs
Normal file
52
WatchLog/Data/Database/Private/PrivateEntity.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
public class PrivateEntity
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public bool Favorite { get; set; } = false;
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
public int? Season { get; set; }
|
||||
|
||||
public int? Episode { get; set; }
|
||||
|
||||
public int? Rating { get; set; }
|
||||
|
||||
[Required]
|
||||
public required DateTime CreationTime { get; set; }
|
||||
|
||||
public DateTime? LastChange { get; set; }
|
||||
|
||||
|
||||
// --- Foreign Keys ---
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int GlobalEntityId { get; set; }
|
||||
|
||||
public int? UserWatchStatusId { get; set; }
|
||||
|
||||
|
||||
// --- Navigation Properties ---
|
||||
[ForeignKey(nameof(UserId))]
|
||||
public virtual User User { get; set; } = null!;
|
||||
|
||||
[ForeignKey(nameof(GlobalEntityId))]
|
||||
public virtual GlobalEntity GlobalEntity { get; set; } = null!;
|
||||
|
||||
[ForeignKey(nameof(UserWatchStatusId))]
|
||||
public virtual UserWatchStatus? UserWatchStatus { get; set; }
|
||||
|
||||
public virtual ICollection<LinkTablePrivateLabel> PrivateEntityLabels { get; set; } = new List<LinkTablePrivateLabel>();
|
||||
|
||||
public virtual ICollection<LinkTablePrivateStreamingPlatform> PrivateStreamingPlatforms { get; set; } = new List<LinkTablePrivateStreamingPlatform>();
|
||||
}
|
||||
}
|
||||
38
WatchLog/Data/Database/Private/UserWatchStatus.cs
Normal file
38
WatchLog/Data/Database/Private/UserWatchStatus.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
public class UserWatchStatus
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[MaxLength(255)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[MaxLength(7)]
|
||||
public string? ColorCode { get; set; }
|
||||
|
||||
[Required]
|
||||
public required DateTime CreationTime { get; set; }
|
||||
|
||||
public DateTime? LastChange { get; set; }
|
||||
|
||||
|
||||
// --- Foreign Key ---
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
|
||||
|
||||
// --- Navigation Properties ---
|
||||
[ForeignKey(nameof(UserId))]
|
||||
public virtual User User { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<PrivateEntity> PrivateEntities { get; set; } = new List<PrivateEntity>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user