Adds Database Structure in C# with Entity Framework
This commit is contained in:
17
WatchLog/Data/Database/Global/Admin.cs
Normal file
17
WatchLog/Data/Database/Global/Admin.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
public class Admin
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
public required string Password { get; set; } // Important: Save as HASH
|
||||
}
|
||||
}
|
||||
23
WatchLog/Data/Database/Global/Genre.cs
Normal file
23
WatchLog/Data/Database/Global/Genre.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
public class Genre
|
||||
{
|
||||
[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; }
|
||||
|
||||
|
||||
// --- Navigation Properties ---
|
||||
public virtual ICollection<LinkTableGlobalGenre> LinkTableGlobalGenres { get; set; } = new List<LinkTableGlobalGenre>();
|
||||
}
|
||||
}
|
||||
45
WatchLog/Data/Database/Global/GlobalEntity.cs
Normal file
45
WatchLog/Data/Database/Global/GlobalEntity.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
public class GlobalEntity
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(200)]
|
||||
public required string Title { get; set; }
|
||||
|
||||
[MaxLength(500)]
|
||||
public string? PicturePath { get; set; }
|
||||
|
||||
[Required]
|
||||
public required DateTime CreationTime { get; set; }
|
||||
|
||||
public DateTime? LastChange { get; set; }
|
||||
|
||||
|
||||
// --- Foreign Keys ---
|
||||
[Required]
|
||||
public int TypeId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CreatorId { get; set; }
|
||||
|
||||
|
||||
// --- Navigation Properties ---
|
||||
[ForeignKey(nameof(TypeId))]
|
||||
public virtual Type Type { get; set; } = null!;
|
||||
|
||||
[ForeignKey(nameof(CreatorId))]
|
||||
public virtual User User { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<LinkTableGlobalGenre> LinkTableGlobalGenres { get; set; } = new List<LinkTableGlobalGenre>();
|
||||
|
||||
public virtual ICollection<PrivateEntity> PrivateEntities { get; set; } = new List<PrivateEntity>();
|
||||
|
||||
public virtual ICollection<SharedListEntity> SharedListEntities { get; set; } = new List<SharedListEntity>();
|
||||
}
|
||||
}
|
||||
24
WatchLog/Data/Database/Global/LinkTableGlobalGenre.cs
Normal file
24
WatchLog/Data/Database/Global/LinkTableGlobalGenre.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
[PrimaryKey(nameof(GlobalEntityId), nameof(GenreId))]
|
||||
public class LinkTableGlobalGenre
|
||||
{
|
||||
// --- Foreign Keys ---
|
||||
[Column(Order = 0)]
|
||||
public int GlobalEntityId { get; set; }
|
||||
|
||||
[Column(Order = 1)]
|
||||
public int GenreId { get; set; }
|
||||
|
||||
|
||||
// --- Navigation Properties ---
|
||||
[ForeignKey(nameof(GlobalEntityId))]
|
||||
public virtual GlobalEntity GlobalEntity { get; set; } = null!;
|
||||
|
||||
[ForeignKey(nameof(GenreId))]
|
||||
public virtual Genre Genre { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
22
WatchLog/Data/Database/Global/StreamingPlatform.cs
Normal file
22
WatchLog/Data/Database/Global/StreamingPlatform.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
public class StreamingPlatform
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
public string? PicturePath { get; set; }
|
||||
|
||||
[Required]
|
||||
public required DateTime CreationTime { get; set; }
|
||||
|
||||
public DateTime? LastChange { get; set; }
|
||||
}
|
||||
}
|
||||
18
WatchLog/Data/Database/Global/Type.cs
Normal file
18
WatchLog/Data/Database/Global/Type.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
public class Type
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public required string Name { get; set; }
|
||||
|
||||
|
||||
// --- Navigation Property ---
|
||||
public virtual ICollection<GlobalEntity> GlobalEntities { get; set; } = new List<GlobalEntity>();
|
||||
}
|
||||
}
|
||||
32
WatchLog/Data/Database/Global/User.cs
Normal file
32
WatchLog/Data/Database/Global/User.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace WatchLog.Data
|
||||
{
|
||||
public class User
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[MaxLength(255)]
|
||||
public string? Email { get; set; }
|
||||
|
||||
[Required]
|
||||
public required string Password { get; set; } // Important: Save as HASH
|
||||
|
||||
|
||||
// --- Navigation Properties ---
|
||||
public virtual ICollection<PrivateEntity> PrivateEntities { get; set; } = new List<PrivateEntity>();
|
||||
|
||||
public virtual ICollection<GlobalEntity> GlobalEntities { get; set; } = new List<GlobalEntity>();
|
||||
|
||||
public virtual ICollection<Label> Labels { get; set; } = new List<Label>();
|
||||
|
||||
public virtual ICollection<UserWatchStatus> UserWatchStatuses { get; set; } = new List<UserWatchStatus>();
|
||||
|
||||
public virtual ICollection<LinkTableSharedUser> LinkTableSharedUsers { get; set; } = new List<LinkTableSharedUser>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user