project reorganized
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
[
|
||||
{
|
||||
"Id": 1,
|
||||
"Name": "Afghanistan"
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"Name": "Albania"
|
||||
}
|
||||
]
|
||||
@@ -1,25 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.DataSeeding
|
||||
{
|
||||
public static class DataReader
|
||||
{
|
||||
#region METHODS
|
||||
|
||||
public static IEnumerable<T> Read<T>() => Read<T>(typeof(T).Name);
|
||||
public static IEnumerable<T> Read<T>(string filename)
|
||||
{
|
||||
string jsonFile = $"..\\WatchIt.Database\\WatchIt.Database.DataSeeding\\Data\\{filename}.json";
|
||||
string dataString = File.ReadAllText(jsonFile);
|
||||
IEnumerable<T> data = JsonConvert.DeserializeObject<IEnumerable<T>>(dataString);
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,121 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Account
|
||||
{
|
||||
public class Account : IEntity<Account>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public short? GenderId { get; set; }
|
||||
public Guid? ProfilePictureId { get; set; }
|
||||
public Guid? BackgroundPictureId { get; set; }
|
||||
public byte[] Password { get; set; }
|
||||
public string LeftSalt { get; set; }
|
||||
public string RightSalt { get; set; }
|
||||
public bool IsAdmin { get; set; } = false;
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime LastActive { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Gender Gender { get; set; }
|
||||
public AccountProfilePicture? ProfilePicture { get; set; }
|
||||
public MediaPhotoImage? BackgroundPicture { get; set; }
|
||||
|
||||
public IEnumerable<RatingMedia> RatingMedia { get; set; }
|
||||
public IEnumerable<RatingPersonActorRole> RatingPersonActorRole { get; set; }
|
||||
public IEnumerable<RatingPersonCreatorRole> RatingPersonCreatorRole { get; set; }
|
||||
public IEnumerable<RatingMediaSeriesSeason> RatingMediaSeriesSeason { get; set; }
|
||||
public IEnumerable<RatingMediaSeriesEpisode> RatingMediaSeriesEpisode { get; set; }
|
||||
|
||||
public IEnumerable<AccountRefreshToken> AccountRefreshTokens { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
static void IEntity<Account>.Build(EntityTypeBuilder<Account> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Username)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Email)
|
||||
.HasMaxLength(320)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.HasOne(x => x.Gender)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.GenderId);
|
||||
builder.Property(x => x.GenderId);
|
||||
|
||||
builder.HasOne(x => x.ProfilePicture)
|
||||
.WithOne(x => x.Account)
|
||||
.HasForeignKey<Account>(e => e.ProfilePictureId);
|
||||
builder.Property(x => x.ProfilePictureId);
|
||||
|
||||
builder.HasOne(x => x.BackgroundPicture)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.BackgroundPictureId);
|
||||
builder.Property(x => x.BackgroundPictureId);
|
||||
|
||||
builder.Property(x => x.Password)
|
||||
.HasMaxLength(1000)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.LeftSalt)
|
||||
.HasMaxLength(20)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.RightSalt)
|
||||
.HasMaxLength(20)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsAdmin)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
|
||||
builder.Property(x => x.CreationDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.LastActive)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
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;
|
||||
|
||||
namespace WatchIt.Database.Model.Account
|
||||
{
|
||||
public class AccountProfilePicture : IEntity<AccountProfilePicture>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public byte[] Image { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
public DateTime UploadDate { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<AccountProfilePicture>.Build(EntityTypeBuilder<AccountProfilePicture> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.Account
|
||||
{
|
||||
public class AccountRefreshToken : IEntity<AccountRefreshToken>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public DateTime ExpirationDate { get; set; }
|
||||
public bool IsExtendable { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<AccountRefreshToken>.Build(EntityTypeBuilder<AccountRefreshToken> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.AccountRefreshTokens)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.ExpirationDate)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsExtendable)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.DataSeeding;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Common
|
||||
{
|
||||
public class Country : IEntity<Country>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public IEnumerable<MediaProductionCountry> MediaProductionCountries { get; set; }
|
||||
public IEnumerable<Media.Media> MediaProduction { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<Country>.Build(EntityTypeBuilder<Country> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.MediaProduction)
|
||||
.WithMany(x => x.ProductionCountries)
|
||||
.UsingEntity<MediaProductionCountry>();
|
||||
}
|
||||
|
||||
static IEnumerable<Country> IEntity<Country>.InsertData() => DataReader.Read<Country>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.DataSeeding;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Common
|
||||
{
|
||||
public class Gender : IEntity<Gender>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<Gender>.Build(EntityTypeBuilder<Gender> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
static IEnumerable<Gender> IEntity<Gender>.InsertData() => DataReader.Read<Gender>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.DataSeeding;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Common
|
||||
{
|
||||
public class Genre : IEntity<Genre>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public IEnumerable<MediaGenre> MediaGenres { get; set; }
|
||||
public IEnumerable<Media.Media> Media { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<Genre>.Build(EntityTypeBuilder<Genre> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.Media)
|
||||
.WithMany(x => x.Genres)
|
||||
.UsingEntity<MediaGenre>();
|
||||
}
|
||||
|
||||
static IEnumerable<Genre> IEntity<Genre>.InsertData() => DataReader.Read<Genre>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model
|
||||
{
|
||||
public static class EntityBuilder
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public static void Build<T>(ModelBuilder builder) where T : class, IEntity<T> => Build<T>(builder.Entity<T>());
|
||||
public static void Build<T>(EntityTypeBuilder<T> builder) where T : class, IEntity<T>
|
||||
{
|
||||
T.Build(builder);
|
||||
builder.HasData(T.InsertData());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model
|
||||
{
|
||||
public interface IEntity<T> where T : class
|
||||
{
|
||||
#region METHODS
|
||||
|
||||
static abstract void Build(EntityTypeBuilder<T> builder);
|
||||
static virtual IEnumerable<T> InsertData() => Array.Empty<T>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Account;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Person;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class Media : IEntity<Media>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string? OriginalTitle { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public DateTime? ReleaseDate { get; set; }
|
||||
public TimeSpan? Length { get; set; }
|
||||
public Guid? MediaPosterImageId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public MediaPosterImage? MediaPosterImage { get; set; }
|
||||
|
||||
public IEnumerable<MediaPhotoImage> MediaPhotoImages { get; set; }
|
||||
|
||||
public IEnumerable<MediaGenre> MediaGenres { get; set; }
|
||||
public IEnumerable<Genre> Genres { get; set; }
|
||||
|
||||
public IEnumerable<MediaProductionCountry> MediaProductionCountries { get; set; }
|
||||
public IEnumerable<Country> ProductionCountries { get; set; }
|
||||
|
||||
public IEnumerable<PersonActorRole> PersonActorRoles { get; set; }
|
||||
|
||||
public IEnumerable<PersonCreatorRole> PersonCreatorRoles { get; set; }
|
||||
|
||||
public IEnumerable<RatingMedia> RatingMedia { get; set; }
|
||||
|
||||
public IEnumerable<ViewCountMedia> ViewCountsMedia { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<Media>.Build(EntityTypeBuilder<Media> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Title)
|
||||
.HasMaxLength(250)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.OriginalTitle)
|
||||
.HasMaxLength(250);
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.Property(x => x.ReleaseDate);
|
||||
|
||||
builder.Property(x => x.Length);
|
||||
|
||||
builder.HasOne(x => x.MediaPosterImage)
|
||||
.WithOne(x => x.Media)
|
||||
.HasForeignKey<Media>(x => x.MediaPosterImageId);
|
||||
builder.Property(x => x.MediaPosterImageId);
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.Genres)
|
||||
.WithMany(x => x.Media)
|
||||
.UsingEntity<MediaGenre>();
|
||||
builder.HasMany(x => x.ProductionCountries)
|
||||
.WithMany(x => x.MediaProduction)
|
||||
.UsingEntity<MediaProductionCountry>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Common;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class MediaGenre : IEntity<MediaGenre>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long MediaId { get; set; }
|
||||
public short GenreId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media Media { get; set; }
|
||||
public Genre Genre { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<MediaGenre>.Build(EntityTypeBuilder<MediaGenre> builder)
|
||||
{
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.MediaGenres)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Genre)
|
||||
.WithMany(x => x.MediaGenres)
|
||||
.HasForeignKey(x => x.GenreId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.GenreId)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class MediaMovie : IEntity<MediaMovie>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long Id { get; set; }
|
||||
public decimal? Budget { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media Media { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<MediaMovie>.Build(EntityTypeBuilder<MediaMovie> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithOne()
|
||||
.HasForeignKey<Media>(x => x.Id)
|
||||
.IsRequired();
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Budget)
|
||||
.HasColumnType("money");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class MediaPhotoImage : IEntity<MediaPhotoImage>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
public byte[] Image { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
public DateTime UploadDate { get; set; }
|
||||
public bool IsMediaBackground { get; set; }
|
||||
public bool IsUniversalBackground { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media Media { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<MediaPhotoImage>.Build(EntityTypeBuilder<MediaPhotoImage> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.MediaPhotoImages)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.IsMediaBackground)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
|
||||
builder.Property(x => x.IsUniversalBackground)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class MediaPosterImage : IEntity<MediaPosterImage>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public byte[] Image { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
public DateTime UploadDate { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media Media { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<MediaPosterImage>.Build(EntityTypeBuilder<MediaPosterImage> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Common;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class MediaProductionCountry : IEntity<MediaProductionCountry>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long MediaId { get; set; }
|
||||
public short CountryId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media Media { get; set; }
|
||||
public Country Country { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<MediaProductionCountry>.Build(EntityTypeBuilder<MediaProductionCountry> builder)
|
||||
{
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.MediaProductionCountries)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Country)
|
||||
.WithMany(x => x.MediaProductionCountries)
|
||||
.HasForeignKey(x => x.CountryId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.CountryId)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class MediaSeries : IEntity<MediaSeries>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long Id { get; set; }
|
||||
public bool HasEnded { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media Media { get; set; }
|
||||
public IEnumerable<MediaSeriesSeason> MediaSeriesSeasons { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<MediaSeries>.Build(EntityTypeBuilder<MediaSeries> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithOne()
|
||||
.HasForeignKey<Media>(x => x.Id)
|
||||
.IsRequired();
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.HasEnded);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class MediaSeriesEpisode : IEntity<MediaSeriesEpisode>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid MediaSeriesSeasonId { get; set; }
|
||||
public short Number { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool IsSpecial { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public MediaSeriesSeason MediaSeriesSeason { get; set; }
|
||||
public IEnumerable<RatingMediaSeriesEpisode> RatingMediaSeriesEpisode { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<MediaSeriesEpisode>.Build(EntityTypeBuilder<MediaSeriesEpisode> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeriesSeason)
|
||||
.WithMany(x => x.MediaSeriesEpisodes)
|
||||
.HasForeignKey(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Number)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name);
|
||||
|
||||
builder.Property(x => x.IsSpecial)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class MediaSeriesSeason : IEntity<MediaSeriesSeason>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long MediaSeriesId { get; set; }
|
||||
public short Number { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public MediaSeries MediaSeries { get; set; }
|
||||
public IEnumerable<MediaSeriesEpisode> MediaSeriesEpisodes { get; set; }
|
||||
public IEnumerable<RatingMediaSeriesSeason> RatingMediaSeriesSeason { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<MediaSeriesSeason>.Build(EntityTypeBuilder<MediaSeriesSeason> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeries)
|
||||
.WithMany(x => x.MediaSeriesSeasons)
|
||||
.HasForeignKey(x => x.MediaSeriesId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Number)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Account;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database.Model.Person
|
||||
{
|
||||
public class Person : IEntity<Person>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string? FullName { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public DateOnly? BirthDate { get; set; }
|
||||
public DateOnly? DeathDate { get; set; }
|
||||
public short GenderId { get; set; }
|
||||
public Guid? PersonPhotoId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Gender Gender { get; set; }
|
||||
public PersonPhotoImage? PersonPhoto { get; set; }
|
||||
public IEnumerable<PersonActorRole> PersonActorRoles { get; set; }
|
||||
public IEnumerable<PersonCreatorRole> PersonCreatorRoles { get; set; }
|
||||
public IEnumerable<ViewCountPerson> ViewCountsPerson { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<Person>.Build(EntityTypeBuilder<Person> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.FullName)
|
||||
.HasMaxLength(200);
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.Property(x => x.BirthDate);
|
||||
|
||||
builder.Property(x => x.DeathDate);
|
||||
|
||||
builder.HasOne(x => x.Gender)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.GenderId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.GenderId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonPhoto)
|
||||
.WithOne(x => x.Person)
|
||||
.HasForeignKey<Person>(e => e.PersonPhotoId);
|
||||
builder.Property(x => x.PersonPhotoId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Person
|
||||
{
|
||||
public class PersonActorRole : IEntity<PersonActorRole>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long PersonId { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
public short PersonActorRoleTypeId { get; set; }
|
||||
public string RoleName { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Person Person { get; set; }
|
||||
public Media.Media Media { get; set; }
|
||||
public PersonActorRoleType PersonActorRoleType { get; set; }
|
||||
|
||||
public IEnumerable<RatingPersonActorRole> RatingPersonActorRole { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<PersonActorRole>.Build(EntityTypeBuilder<PersonActorRole> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Person)
|
||||
.WithMany(x => x.PersonActorRoles)
|
||||
.HasForeignKey(x => x.PersonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.PersonActorRoles)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonActorRoleType)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.PersonActorRoleTypeId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonActorRoleTypeId)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.DataSeeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Person
|
||||
{
|
||||
public class PersonActorRoleType : IEntity<PersonActorRoleType>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<PersonActorRoleType>.Build(EntityTypeBuilder<PersonActorRoleType> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
static IEnumerable<PersonActorRoleType> IEntity<PersonActorRoleType>.InsertData() => DataReader.Read<PersonActorRoleType>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Person
|
||||
{
|
||||
public class PersonCreatorRole : IEntity<PersonCreatorRole>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long PersonId { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
public short PersonCreatorRoleTypeId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Person Person { get; set; }
|
||||
public Media.Media Media { get; set; }
|
||||
public PersonCreatorRoleType PersonCreatorRoleType { get; set; }
|
||||
public IEnumerable<RatingPersonCreatorRole> RatingPersonCreatorRole { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<PersonCreatorRole>.Build(EntityTypeBuilder<PersonCreatorRole> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Person)
|
||||
.WithMany(x => x.PersonCreatorRoles)
|
||||
.HasForeignKey(x => x.PersonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.PersonCreatorRoles)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonCreatorRoleType)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.PersonCreatorRoleTypeId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonCreatorRoleTypeId)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.DataSeeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Person
|
||||
{
|
||||
public class PersonCreatorRoleType : IEntity<PersonCreatorRoleType>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<PersonCreatorRoleType>.Build(EntityTypeBuilder<PersonCreatorRoleType> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
static IEnumerable<PersonCreatorRoleType> IEntity<PersonCreatorRoleType>.InsertData() => DataReader.Read<PersonCreatorRoleType>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Account;
|
||||
|
||||
namespace WatchIt.Database.Model.Person
|
||||
{
|
||||
public class PersonPhotoImage : IEntity<PersonPhotoImage>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public byte[] Image { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
public DateTime UploadDate { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Person Person { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<PersonPhotoImage>.Build(EntityTypeBuilder<PersonPhotoImage> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating
|
||||
{
|
||||
public class RatingMedia : IEntity<RatingMedia>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media.Media Media { get; set; }
|
||||
public Account.Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<RatingMedia>.Build(EntityTypeBuilder<RatingMedia> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.RatingMedia)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingMedia)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating
|
||||
{
|
||||
public class RatingMediaSeriesEpisode : IEntity<RatingMediaSeriesEpisode>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid MediaSeriesEpisodeId { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public MediaSeriesEpisode MediaSeriesEpisode { get; set; }
|
||||
public Account.Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<RatingMediaSeriesEpisode>.Build(EntityTypeBuilder<RatingMediaSeriesEpisode> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeriesEpisode)
|
||||
.WithMany(x => x.RatingMediaSeriesEpisode)
|
||||
.HasForeignKey(x => x.MediaSeriesEpisodeId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesEpisodeId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingMediaSeriesEpisode)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating
|
||||
{
|
||||
public class RatingMediaSeriesSeason : IEntity<RatingMediaSeriesSeason>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid MediaSeriesSeasonId { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public MediaSeriesSeason MediaSeriesSeason { get; set; }
|
||||
public Account.Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<RatingMediaSeriesSeason>.Build(EntityTypeBuilder<RatingMediaSeriesSeason> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeriesSeason)
|
||||
.WithMany(x => x.RatingMediaSeriesSeason)
|
||||
.HasForeignKey(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingMediaSeriesSeason)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating
|
||||
{
|
||||
public class RatingPersonActorRole : IEntity<RatingPersonActorRole>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid PersonActorRoleId { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public PersonActorRole PersonActorRole { get; set; }
|
||||
public Account.Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<RatingPersonActorRole>.Build(EntityTypeBuilder<RatingPersonActorRole> builder)
|
||||
{
|
||||
builder.ToTable("RatingsPersonActorRole");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonActorRole)
|
||||
.WithMany(x => x.RatingPersonActorRole)
|
||||
.HasForeignKey(x => x.PersonActorRoleId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonActorRoleId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingPersonActorRole)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating
|
||||
{
|
||||
public class RatingPersonCreatorRole : IEntity<RatingPersonCreatorRole>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid PersonCreatorRoleId { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public PersonCreatorRole PersonCreatorRole { get; set; }
|
||||
public Account.Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<RatingPersonCreatorRole>.Build(EntityTypeBuilder<RatingPersonCreatorRole> builder)
|
||||
{
|
||||
builder.ToTable("RatingsPersonCreatorRole");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonCreatorRole)
|
||||
.WithMany(x => x.RatingPersonCreatorRole)
|
||||
.HasForeignKey(x => x.PersonCreatorRoleId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonCreatorRoleId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingPersonCreatorRole)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.ViewCount
|
||||
{
|
||||
public class ViewCountMedia : IEntity<ViewCountMedia>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
public long ViewCount { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media.Media Media { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<ViewCountMedia>.Build(EntityTypeBuilder<ViewCountMedia> builder)
|
||||
{
|
||||
builder.ToTable("ViewCountsMedia");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.ViewCountsMedia)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Date)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.ViewCount)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.ViewCount
|
||||
{
|
||||
public class ViewCountPerson : IEntity<ViewCountPerson>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long PersonId { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
public long ViewCount { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Person.Person Person { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<ViewCountPerson>.Build(EntityTypeBuilder<ViewCountPerson> builder)
|
||||
{
|
||||
builder.ToTable("ViewCountsPerson");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Person)
|
||||
.WithMany(x => x.ViewCountsPerson)
|
||||
.HasForeignKey(x => x.PersonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Date)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.ViewCount)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Account;
|
||||
|
||||
public class AccountConfiguration : IEntityTypeConfiguration<Model.Account.Account>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Model.Account.Account> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Username)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Email)
|
||||
.HasMaxLength(320)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.HasOne(x => x.Gender)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.GenderId);
|
||||
builder.Property(x => x.GenderId);
|
||||
|
||||
builder.HasOne(x => x.ProfilePicture)
|
||||
.WithOne(x => x.Account)
|
||||
.HasForeignKey<Model.Account.Account>(e => e.ProfilePictureId);
|
||||
builder.Property(x => x.ProfilePictureId);
|
||||
|
||||
builder.HasOne(x => x.BackgroundPicture)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.BackgroundPictureId);
|
||||
builder.Property(x => x.BackgroundPictureId);
|
||||
|
||||
builder.Property(x => x.Password)
|
||||
.HasMaxLength(1000)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.LeftSalt)
|
||||
.HasMaxLength(20)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.RightSalt)
|
||||
.HasMaxLength(20)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsAdmin)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
|
||||
builder.Property(x => x.CreationDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.LastActive)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Account;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Account;
|
||||
|
||||
public class AccountProfilePictureConfiguration : IEntityTypeConfiguration<AccountProfilePicture>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<AccountProfilePicture> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Account;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Account;
|
||||
|
||||
public class AccountRefreshTokenConfiguration : IEntityTypeConfiguration<AccountRefreshToken>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<AccountRefreshToken> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.AccountRefreshTokens)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.ExpirationDate)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsExtendable)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Seeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Common;
|
||||
|
||||
public class CountryConfiguration : IEntityTypeConfiguration<Country>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Country> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsHistorical)
|
||||
.HasDefaultValue(false)
|
||||
.IsRequired();
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.MediaProduction)
|
||||
.WithMany(x => x.ProductionCountries)
|
||||
.UsingEntity<MediaProductionCountry>();
|
||||
|
||||
// Data
|
||||
builder.HasData(DataReader.Read<Country>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Seeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Common;
|
||||
|
||||
public class GenderConfiguration : IEntityTypeConfiguration<Gender>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Gender> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.IsRequired();
|
||||
|
||||
// Data
|
||||
builder.HasData(DataReader.Read<Gender>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Seeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Common;
|
||||
|
||||
public class GenreConfiguration : IEntityTypeConfiguration<Genre>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Genre> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.Media)
|
||||
.WithMany(x => x.Genres)
|
||||
.UsingEntity<MediaGenre>();
|
||||
|
||||
// Data
|
||||
builder.HasData(DataReader.Read<Genre>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaConfiguration : IEntityTypeConfiguration<Model.Media.Media>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Model.Media.Media> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Title)
|
||||
.HasMaxLength(250)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.OriginalTitle)
|
||||
.HasMaxLength(250);
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.Property(x => x.ReleaseDate);
|
||||
|
||||
builder.Property(x => x.Length);
|
||||
|
||||
builder.HasOne(x => x.MediaPosterImage)
|
||||
.WithOne(x => x.Media)
|
||||
.HasForeignKey<Model.Media.Media>(x => x.MediaPosterImageId);
|
||||
builder.Property(x => x.MediaPosterImageId);
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.Genres)
|
||||
.WithMany(x => x.Media)
|
||||
.UsingEntity<MediaGenre>();
|
||||
builder.HasMany(x => x.ProductionCountries)
|
||||
.WithMany(x => x.MediaProduction)
|
||||
.UsingEntity<MediaProductionCountry>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaGenreConfiguration : IEntityTypeConfiguration<MediaGenre>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaGenre> builder)
|
||||
{
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.MediaGenres)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Genre)
|
||||
.WithMany(x => x.MediaGenres)
|
||||
.HasForeignKey(x => x.GenreId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.GenreId)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaMovieConfiguration : IEntityTypeConfiguration<MediaMovie>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaMovie> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithOne()
|
||||
.HasForeignKey<MediaMovie>(x => x.Id)
|
||||
.IsRequired();
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Budget)
|
||||
.HasColumnType("money");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaPhotoImageConfiguration : IEntityTypeConfiguration<MediaPhotoImage>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaPhotoImage> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.MediaPhotoImages)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.IsMediaBackground)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
|
||||
builder.Property(x => x.IsUniversalBackground)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaPosterImageConfiguration : IEntityTypeConfiguration<MediaPosterImage>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaPosterImage> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaProductionCountryConfiguration : IEntityTypeConfiguration<MediaProductionCountry>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaProductionCountry> builder)
|
||||
{
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.MediaProductionCountries)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Country)
|
||||
.WithMany(x => x.MediaProductionCountries)
|
||||
.HasForeignKey(x => x.CountryId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.CountryId)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaSeriesConfiguration : IEntityTypeConfiguration<MediaSeries>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaSeries> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithOne()
|
||||
.HasForeignKey<MediaSeries>(x => x.Id)
|
||||
.IsRequired();
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.HasEnded)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaSeriesEpisodeConfiguration : IEntityTypeConfiguration<MediaSeriesEpisode>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaSeriesEpisode> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeriesSeason)
|
||||
.WithMany(x => x.MediaSeriesEpisodes)
|
||||
.HasForeignKey(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Number)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name);
|
||||
|
||||
builder.Property(x => x.IsSpecial)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaSeriesSeasonConfiguration : IEntityTypeConfiguration<MediaSeriesSeason>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaSeriesSeason> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeries)
|
||||
.WithMany(x => x.MediaSeriesSeasons)
|
||||
.HasForeignKey(x => x.MediaSeriesId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Number)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonActorRoleConfiguration : IEntityTypeConfiguration<PersonActorRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PersonActorRole> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Person)
|
||||
.WithMany(x => x.PersonActorRoles)
|
||||
.HasForeignKey(x => x.PersonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.PersonActorRoles)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonActorRoleType)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.PersonActorRoleTypeId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonActorRoleTypeId)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Person;
|
||||
using WatchIt.Database.Model.Seeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonActorRoleTypeConfiguration : IEntityTypeConfiguration<PersonActorRoleType>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PersonActorRoleType> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
// Data
|
||||
builder.HasData(DataReader.Read<PersonActorRoleType>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonConfiguration : IEntityTypeConfiguration<Model.Person.Person>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Model.Person.Person> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.FullName)
|
||||
.HasMaxLength(200);
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.Property(x => x.BirthDate);
|
||||
|
||||
builder.Property(x => x.DeathDate);
|
||||
|
||||
builder.HasOne(x => x.Gender)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.GenderId);
|
||||
builder.Property(x => x.GenderId);
|
||||
|
||||
builder.HasOne(x => x.PersonPhoto)
|
||||
.WithOne(x => x.Person)
|
||||
.HasForeignKey<Model.Person.Person>(e => e.PersonPhotoId);
|
||||
builder.Property(x => x.PersonPhotoId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonCreatorRoleConfiguration : IEntityTypeConfiguration<PersonCreatorRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PersonCreatorRole> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Person)
|
||||
.WithMany(x => x.PersonCreatorRoles)
|
||||
.HasForeignKey(x => x.PersonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.PersonCreatorRoles)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonCreatorRoleType)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.PersonCreatorRoleTypeId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonCreatorRoleTypeId)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Person;
|
||||
using WatchIt.Database.Model.Seeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonCreatorRoleTypeConfiguration : IEntityTypeConfiguration<PersonCreatorRoleType>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PersonCreatorRoleType> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
// Data
|
||||
builder.HasData(DataReader.Read<PersonCreatorRoleType>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonPhotoImageConfiguration : IEntityTypeConfiguration<PersonPhotoImage>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PersonPhotoImage> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Rating;
|
||||
|
||||
public class RatingMediaConfiguration : IEntityTypeConfiguration<RatingMedia>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<RatingMedia> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.RatingMedia)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingMedia)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Rating;
|
||||
|
||||
public class RatingMediaSeriesEpisodeConfiguration : IEntityTypeConfiguration<RatingMediaSeriesEpisode>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<RatingMediaSeriesEpisode> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeriesEpisode)
|
||||
.WithMany(x => x.RatingMediaSeriesEpisode)
|
||||
.HasForeignKey(x => x.MediaSeriesEpisodeId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesEpisodeId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingMediaSeriesEpisode)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Rating;
|
||||
|
||||
public class RatingMediaSeriesSeasonConfiguration : IEntityTypeConfiguration<RatingMediaSeriesSeason>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<RatingMediaSeriesSeason> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeriesSeason)
|
||||
.WithMany(x => x.RatingMediaSeriesSeason)
|
||||
.HasForeignKey(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingMediaSeriesSeason)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Rating;
|
||||
|
||||
public class RatingPersonActorRoleConfiguration : IEntityTypeConfiguration<RatingPersonActorRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<RatingPersonActorRole> builder)
|
||||
{
|
||||
builder.ToTable("RatingsPersonActorRole");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonActorRole)
|
||||
.WithMany(x => x.RatingPersonActorRole)
|
||||
.HasForeignKey(x => x.PersonActorRoleId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonActorRoleId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingPersonActorRole)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Rating;
|
||||
|
||||
public class RatingPersonCreatorRoleConfiguration : IEntityTypeConfiguration<RatingPersonCreatorRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<RatingPersonCreatorRole> builder)
|
||||
{
|
||||
builder.ToTable("RatingsPersonCreatorRole");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonCreatorRole)
|
||||
.WithMany(x => x.RatingPersonCreatorRole)
|
||||
.HasForeignKey(x => x.PersonCreatorRoleId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonCreatorRoleId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingPersonCreatorRole)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.ViewCount;
|
||||
|
||||
public class ViewCountMediaConfiguration : IEntityTypeConfiguration<ViewCountMedia>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ViewCountMedia> builder)
|
||||
{
|
||||
builder.ToTable("ViewCountsMedia");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.ViewCountsMedia)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Date)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.ViewCount)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.ViewCount;
|
||||
|
||||
public class ViewCountPersonConfiguration : IEntityTypeConfiguration<ViewCountPerson>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ViewCountPerson> builder)
|
||||
{
|
||||
builder.ToTable("ViewCountsPerson");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Person)
|
||||
.WithMany(x => x.ViewCountsPerson)
|
||||
.HasForeignKey(x => x.PersonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Date)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.ViewCount)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WatchIt.Database.Model.Seeding\WatchIt.Database.Model.Seeding.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.Database.Model\WatchIt.Database.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"Id": 1,
|
||||
"Name": "Afghanistan",
|
||||
"IsHistorical": false
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"Name": "Albania",
|
||||
"IsHistorical": false
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace WatchIt.Database.Model.Seeding;
|
||||
|
||||
public class DataReader
|
||||
{
|
||||
#region METHODS
|
||||
|
||||
public static IEnumerable<T> Read<T>() => Read<T>(typeof(T).Name);
|
||||
public static IEnumerable<T> Read<T>(string filename)
|
||||
{
|
||||
string jsonFile = $@"..\..\WatchIt.Database\WatchIt.Database.Model\WatchIt.Database.Model.Seeding\Data\{filename}.json";
|
||||
string dataString = File.ReadAllText(jsonFile);
|
||||
IEnumerable<T>? data = JsonSerializer.Deserialize<IEnumerable<T>>(dataString);
|
||||
if (data is null)
|
||||
{
|
||||
throw new JsonException();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,20 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WatchIt.Database.DataSeeding\WatchIt.Database.DataSeeding.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,44 @@
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Account;
|
||||
|
||||
public class Account
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long Id { get; set; }
|
||||
public required string Username { get; set; }
|
||||
public required string Email { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public short? GenderId { get; set; }
|
||||
public Guid? ProfilePictureId { get; set; }
|
||||
public Guid? BackgroundPictureId { get; set; }
|
||||
public required byte[] Password { get; set; }
|
||||
public required string LeftSalt { get; set; }
|
||||
public required string RightSalt { get; set; }
|
||||
public bool IsAdmin { get; set; } = false;
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime LastActive { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Gender? Gender { get; set; }
|
||||
public virtual AccountProfilePicture? ProfilePicture { get; set; }
|
||||
public virtual MediaPhotoImage? BackgroundPicture { get; set; }
|
||||
|
||||
public virtual IEnumerable<RatingMedia> RatingMedia { get; set; } = new List<RatingMedia>();
|
||||
public virtual IEnumerable<RatingPersonActorRole> RatingPersonActorRole { get; set; } = new List<RatingPersonActorRole>();
|
||||
public virtual IEnumerable<RatingPersonCreatorRole> RatingPersonCreatorRole { get; set; } = new List<RatingPersonCreatorRole>();
|
||||
public virtual IEnumerable<RatingMediaSeriesSeason> RatingMediaSeriesSeason { get; set; } = new List<RatingMediaSeriesSeason>();
|
||||
public virtual IEnumerable<RatingMediaSeriesEpisode> RatingMediaSeriesEpisode { get; set; } = new List<RatingMediaSeriesEpisode>();
|
||||
|
||||
public virtual IEnumerable<AccountRefreshToken> AccountRefreshTokens { get; set; } = new List<AccountRefreshToken>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace WatchIt.Database.Model.Account;
|
||||
|
||||
public class AccountProfilePicture
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required byte[] Image { get; set; }
|
||||
public required string MimeType { get; set; }
|
||||
public DateTime UploadDate { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Account Account { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace WatchIt.Database.Model.Account;
|
||||
|
||||
public class AccountRefreshToken
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required long AccountId { get; set; }
|
||||
public required DateTime ExpirationDate { get; set; }
|
||||
public required bool IsExtendable { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Account Account { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Common;
|
||||
|
||||
public class Country
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public bool IsHistorical { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual IEnumerable<MediaProductionCountry> MediaProductionCountries { get; set; } = new List<MediaProductionCountry>();
|
||||
public virtual IEnumerable<Media.Media> MediaProduction { get; set; } = new List<Media.Media>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace WatchIt.Database.Model.Common;
|
||||
|
||||
public class Gender
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Common;
|
||||
|
||||
public class Genre
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual IEnumerable<MediaGenre> MediaGenres { get; set; } = new List<MediaGenre>();
|
||||
public virtual IEnumerable<Media.Media> Media { get; set; } = new List<Media.Media>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Person;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database.Model.Media;
|
||||
|
||||
public class Media
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long Id { get; set; }
|
||||
public required string Title { get; set; }
|
||||
public string? OriginalTitle { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public DateOnly? ReleaseDate { get; set; }
|
||||
public short? Length { get; set; }
|
||||
public Guid? MediaPosterImageId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual MediaPosterImage? MediaPosterImage { get; set; }
|
||||
|
||||
public virtual IEnumerable<MediaPhotoImage> MediaPhotoImages { get; set; } = new List<MediaPhotoImage>();
|
||||
|
||||
public virtual IEnumerable<MediaGenre> MediaGenres { get; set; } = new List<MediaGenre>();
|
||||
public virtual IEnumerable<Genre> Genres { get; set; } = new List<Genre>();
|
||||
|
||||
public virtual IEnumerable<MediaProductionCountry> MediaProductionCountries { get; set; } = new List<MediaProductionCountry>();
|
||||
public virtual IEnumerable<Country> ProductionCountries { get; set; } = new List<Country>();
|
||||
|
||||
public virtual IEnumerable<PersonActorRole> PersonActorRoles { get; set; } = new List<PersonActorRole>();
|
||||
|
||||
public virtual IEnumerable<PersonCreatorRole> PersonCreatorRoles { get; set; } = new List<PersonCreatorRole>();
|
||||
|
||||
public virtual IEnumerable<RatingMedia> RatingMedia { get; set; } = new List<RatingMedia>();
|
||||
|
||||
public virtual IEnumerable<ViewCountMedia> ViewCountsMedia { get; set; } = new List<ViewCountMedia>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using WatchIt.Database.Model.Common;
|
||||
|
||||
namespace WatchIt.Database.Model.Media;
|
||||
|
||||
public class MediaGenre
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public required long MediaId { get; set; }
|
||||
public required short GenreId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Media Media { get; set; } = null!;
|
||||
public virtual Genre Genre { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace WatchIt.Database.Model.Media;
|
||||
|
||||
public class MediaMovie
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long Id { get; set; }
|
||||
public decimal? Budget { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Media Media { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace WatchIt.Database.Model.Media;
|
||||
|
||||
public class MediaPhotoImage
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required long MediaId { get; set; }
|
||||
public required byte[] Image { get; set; }
|
||||
public required string MimeType { get; set; }
|
||||
public DateTime UploadDate { get; set; }
|
||||
public bool IsMediaBackground { get; set; }
|
||||
public bool IsUniversalBackground { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Media Media { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace WatchIt.Database.Model.Media;
|
||||
|
||||
public class MediaPosterImage
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required byte[] Image { get; set; }
|
||||
public required string MimeType { get; set; }
|
||||
public required DateTime UploadDate { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Media Media { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using WatchIt.Database.Model.Common;
|
||||
|
||||
namespace WatchIt.Database.Model.Media;
|
||||
|
||||
public class MediaProductionCountry
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public required long MediaId { get; set; }
|
||||
public required short CountryId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Media Media { get; set; } = null!;
|
||||
public virtual Country Country { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace WatchIt.Database.Model.Media;
|
||||
|
||||
public class MediaSeries
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public required long Id { get; set; }
|
||||
public bool HasEnded { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Media Media { get; set; } = null!;
|
||||
public virtual IEnumerable<MediaSeriesSeason> MediaSeriesSeasons { get; set; } = new List<MediaSeriesSeason>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Media;
|
||||
|
||||
public class MediaSeriesEpisode
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required Guid MediaSeriesSeasonId { get; set; }
|
||||
public required short Number { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool IsSpecial { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual MediaSeriesSeason MediaSeriesSeason { get; set; } = null!;
|
||||
public virtual IEnumerable<RatingMediaSeriesEpisode> RatingMediaSeriesEpisode { get; set; } = new List<RatingMediaSeriesEpisode>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Media;
|
||||
|
||||
public class MediaSeriesSeason
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required long MediaSeriesId { get; set; }
|
||||
public required short Number { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual MediaSeries MediaSeries { get; set; } = null!;
|
||||
public virtual IEnumerable<MediaSeriesEpisode> MediaSeriesEpisodes { get; set; } = new List<MediaSeriesEpisode>();
|
||||
public virtual IEnumerable<RatingMediaSeriesSeason> RatingMediaSeriesSeason { get; set; } = new List<RatingMediaSeriesSeason>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database.Model.Person;
|
||||
|
||||
public class Person
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public string? FullName { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public DateOnly? BirthDate { get; set; }
|
||||
public DateOnly? DeathDate { get; set; }
|
||||
public short? GenderId { get; set; }
|
||||
public Guid? PersonPhotoId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Gender? Gender { get; set; }
|
||||
public virtual PersonPhotoImage? PersonPhoto { get; set; }
|
||||
public virtual IEnumerable<PersonActorRole> PersonActorRoles { get; set; } = new List<PersonActorRole>();
|
||||
public virtual IEnumerable<PersonCreatorRole> PersonCreatorRoles { get; set; } = new List<PersonCreatorRole>();
|
||||
public virtual IEnumerable<ViewCountPerson> ViewCountsPerson { get; set; } = new List<ViewCountPerson>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Person;
|
||||
|
||||
public class PersonActorRole
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required long PersonId { get; set; }
|
||||
public required long MediaId { get; set; }
|
||||
public required short PersonActorRoleTypeId { get; set; }
|
||||
public required string RoleName { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Person Person { get; set; } = null!;
|
||||
public virtual Media.Media Media { get; set; } = null!;
|
||||
public virtual PersonActorRoleType PersonActorRoleType { get; set; } = null!;
|
||||
|
||||
public virtual IEnumerable<RatingPersonActorRole> RatingPersonActorRole { get; set; } = new List<RatingPersonActorRole>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace WatchIt.Database.Model.Person;
|
||||
|
||||
public class PersonActorRoleType
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Person;
|
||||
|
||||
public class PersonCreatorRole
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required long PersonId { get; set; }
|
||||
public required long MediaId { get; set; }
|
||||
public required short PersonCreatorRoleTypeId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Person Person { get; set; } = null!;
|
||||
public virtual Media.Media Media { get; set; } = null!;
|
||||
public virtual PersonCreatorRoleType PersonCreatorRoleType { get; set; } = null!;
|
||||
public virtual IEnumerable<RatingPersonCreatorRole> RatingPersonCreatorRole { get; set; } = new List<RatingPersonCreatorRole>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace WatchIt.Database.Model.Person;
|
||||
|
||||
public class PersonCreatorRoleType
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace WatchIt.Database.Model.Person;
|
||||
|
||||
public class PersonPhotoImage
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required byte[] Image { get; set; }
|
||||
public required string MimeType { get; set; }
|
||||
public DateTime UploadDate { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Person Person { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace WatchIt.Database.Model.Rating;
|
||||
|
||||
public class RatingMedia
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required long MediaId { get; set; }
|
||||
public required long AccountId { get; set; }
|
||||
public required short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Model.Media.Media Media { get; set; } = null!;
|
||||
public virtual Model.Account.Account Account { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating;
|
||||
|
||||
public class RatingMediaSeriesEpisode
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required Guid MediaSeriesEpisodeId { get; set; }
|
||||
public required long AccountId { get; set; }
|
||||
public required short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual MediaSeriesEpisode MediaSeriesEpisode { get; set; } = null!;
|
||||
public virtual Account.Account Account { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating;
|
||||
|
||||
public class RatingMediaSeriesSeason
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required Guid MediaSeriesSeasonId { get; set; }
|
||||
public required long AccountId { get; set; }
|
||||
public required short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual MediaSeriesSeason MediaSeriesSeason { get; set; } = null!;
|
||||
public virtual Account.Account Account { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating;
|
||||
|
||||
public class RatingPersonActorRole
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required Guid PersonActorRoleId { get; set; }
|
||||
public required long AccountId { get; set; }
|
||||
public required short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual PersonActorRole PersonActorRole { get; set; } = null!;
|
||||
public virtual Account.Account Account { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating;
|
||||
|
||||
public class RatingPersonCreatorRole
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required Guid PersonCreatorRoleId { get; set; }
|
||||
public required long AccountId { get; set; }
|
||||
public required short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual PersonCreatorRole PersonCreatorRole { get; set; } = null!;
|
||||
public virtual Account.Account Account { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace WatchIt.Database.Model.ViewCount;
|
||||
|
||||
public class ViewCountMedia
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required long MediaId { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
public long ViewCount { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Media.Media Media { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace WatchIt.Database.Model.ViewCount;
|
||||
|
||||
public class ViewCountPerson
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public required long PersonId { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
public long ViewCount { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public virtual Person.Person Person { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,126 +1,114 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using SimpleToolkit.Extensions;
|
||||
using WatchIt.Database.Model.Account;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Configuration.Account;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Person;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database
|
||||
namespace WatchIt.Database;
|
||||
|
||||
public class DatabaseContext : DbContext
|
||||
{
|
||||
public class DatabaseContext : DbContext
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public DatabaseContext()
|
||||
{
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public DatabaseContext() { }
|
||||
|
||||
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
// Common
|
||||
public virtual DbSet<Country> Countries { get; set; }
|
||||
public virtual DbSet<Genre> Genres { get; set; }
|
||||
public virtual DbSet<Gender> Genders { get; set; }
|
||||
|
||||
// Account
|
||||
public virtual DbSet<Account> Accounts { get; set; }
|
||||
public virtual DbSet<AccountProfilePicture> AccountProfilePictures { get; set; }
|
||||
public virtual DbSet<AccountRefreshToken> AccountRefreshTokens { get; set; }
|
||||
|
||||
// Media
|
||||
public virtual DbSet<Media> Media { get; set; }
|
||||
public virtual DbSet<MediaMovie> MediaMovies { get; set; }
|
||||
public virtual DbSet<MediaSeries> MediaSeries { get; set; }
|
||||
public virtual DbSet<MediaSeriesSeason> MediaSeriesSeasons { get; set; }
|
||||
public virtual DbSet<MediaSeriesEpisode> MediaSeriesEpisodes { get; set; }
|
||||
public virtual DbSet<MediaPosterImage> MediaPosterImages { get; set; }
|
||||
public virtual DbSet<MediaPhotoImage> MediaPhotoImages { get; set; }
|
||||
public virtual DbSet<MediaGenre> MediaGenres { get; set; }
|
||||
public virtual DbSet<MediaProductionCountry> MediaProductionCountrys { get; set; }
|
||||
|
||||
// Person
|
||||
public virtual DbSet<Person> Persons { get; set; }
|
||||
public virtual DbSet<PersonPhotoImage> PersonPhotoImages { get; set; }
|
||||
public virtual DbSet<PersonActorRole> PersonActorRoles { get; set; }
|
||||
public virtual DbSet<PersonActorRoleType> PersonActorRoleTypes { get; set; }
|
||||
public virtual DbSet<PersonCreatorRole> PersonCreatorRoles { get; set; }
|
||||
public virtual DbSet<PersonCreatorRoleType> PersonCreatorRoleTypes { get; set; }
|
||||
|
||||
// Rating
|
||||
public virtual DbSet<RatingMedia> RatingsMedia { get; set; }
|
||||
public virtual DbSet<RatingPersonActorRole> RatingsPersonActorRole { get; set; }
|
||||
public virtual DbSet<RatingPersonActorRole> RatingsPersonCreatorRole { get; set; }
|
||||
public virtual DbSet<RatingMediaSeriesSeason> RatingsMediaSeriesSeason { get; set; }
|
||||
public virtual DbSet<RatingMediaSeriesEpisode> RatingsMediaSeriesEpisode { get; set; }
|
||||
|
||||
// ViewCount
|
||||
public virtual DbSet<ViewCountPerson> ViewCountsPerson { get; set; }
|
||||
public virtual DbSet<ViewCountMedia> ViewCountsMedia { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseNpgsql("name=Default");
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
// Common
|
||||
EntityBuilder.Build<Country>(modelBuilder);
|
||||
EntityBuilder.Build<Genre>(modelBuilder);
|
||||
EntityBuilder.Build<Gender>(modelBuilder);
|
||||
|
||||
// Account
|
||||
EntityBuilder.Build<Account>(modelBuilder);
|
||||
EntityBuilder.Build<AccountProfilePicture>(modelBuilder);
|
||||
EntityBuilder.Build<AccountRefreshToken>(modelBuilder);
|
||||
|
||||
// Media
|
||||
EntityBuilder.Build<Media>(modelBuilder);
|
||||
EntityBuilder.Build<MediaMovie>(modelBuilder);
|
||||
EntityBuilder.Build<MediaSeries>(modelBuilder);
|
||||
EntityBuilder.Build<MediaSeriesSeason>(modelBuilder);
|
||||
EntityBuilder.Build<MediaSeriesEpisode>(modelBuilder);
|
||||
EntityBuilder.Build<MediaPosterImage>(modelBuilder);
|
||||
EntityBuilder.Build<MediaPhotoImage>(modelBuilder);
|
||||
EntityBuilder.Build<MediaGenre>(modelBuilder);
|
||||
EntityBuilder.Build<MediaProductionCountry>(modelBuilder);
|
||||
|
||||
// Person
|
||||
EntityBuilder.Build<Person>(modelBuilder);
|
||||
EntityBuilder.Build<PersonPhotoImage>(modelBuilder);
|
||||
EntityBuilder.Build<PersonActorRole>(modelBuilder);
|
||||
EntityBuilder.Build<PersonActorRoleType>(modelBuilder);
|
||||
EntityBuilder.Build<PersonCreatorRole>(modelBuilder);
|
||||
EntityBuilder.Build<PersonCreatorRoleType>(modelBuilder);
|
||||
|
||||
// Rating
|
||||
EntityBuilder.Build<RatingMedia>(modelBuilder);
|
||||
EntityBuilder.Build<RatingPersonActorRole>(modelBuilder);
|
||||
EntityBuilder.Build<RatingPersonCreatorRole>(modelBuilder);
|
||||
EntityBuilder.Build<RatingMediaSeriesSeason>(modelBuilder);
|
||||
EntityBuilder.Build<RatingMediaSeriesEpisode>(modelBuilder);
|
||||
|
||||
// ViewCounts
|
||||
EntityBuilder.Build<ViewCountMedia>(modelBuilder);
|
||||
EntityBuilder.Build<ViewCountPerson>(modelBuilder);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
// Common
|
||||
public virtual DbSet<Country> Countries { get; set; }
|
||||
public virtual DbSet<Genre> Genres { get; set; }
|
||||
public virtual DbSet<Gender> Genders { get; set; }
|
||||
|
||||
// Account
|
||||
public virtual DbSet<Account> Accounts { get; set; }
|
||||
public virtual DbSet<AccountProfilePicture> AccountProfilePictures { get; set; }
|
||||
public virtual DbSet<AccountRefreshToken> AccountRefreshTokens { get; set; }
|
||||
|
||||
// Media
|
||||
public virtual DbSet<Media> Media { get; set; }
|
||||
public virtual DbSet<MediaMovie> MediaMovies { get; set; }
|
||||
public virtual DbSet<MediaSeries> MediaSeries { get; set; }
|
||||
public virtual DbSet<MediaSeriesSeason> MediaSeriesSeasons { get; set; }
|
||||
public virtual DbSet<MediaSeriesEpisode> MediaSeriesEpisodes { get; set; }
|
||||
public virtual DbSet<MediaPosterImage> MediaPosterImages { get; set; }
|
||||
public virtual DbSet<MediaPhotoImage> MediaPhotoImages { get; set; }
|
||||
public virtual DbSet<MediaGenre> MediaGenres { get; set; }
|
||||
public virtual DbSet<MediaProductionCountry> MediaProductionCountries { get; set; }
|
||||
|
||||
// Person
|
||||
public virtual DbSet<Person> Persons { get; set; }
|
||||
public virtual DbSet<PersonPhotoImage> PersonPhotoImages { get; set; }
|
||||
public virtual DbSet<PersonActorRole> PersonActorRoles { get; set; }
|
||||
public virtual DbSet<PersonActorRoleType> PersonActorRoleTypes { get; set; }
|
||||
public virtual DbSet<PersonCreatorRole> PersonCreatorRoles { get; set; }
|
||||
public virtual DbSet<PersonCreatorRoleType> PersonCreatorRoleTypes { get; set; }
|
||||
|
||||
// Rating
|
||||
public virtual DbSet<RatingMedia> RatingsMedia { get; set; }
|
||||
public virtual DbSet<RatingPersonActorRole> RatingsPersonActorRole { get; set; }
|
||||
public virtual DbSet<RatingPersonActorRole> RatingsPersonCreatorRole { get; set; }
|
||||
public virtual DbSet<RatingMediaSeriesSeason> RatingsMediaSeriesSeason { get; set; }
|
||||
public virtual DbSet<RatingMediaSeriesEpisode> RatingsMediaSeriesEpisode { get; set; }
|
||||
|
||||
// ViewCount
|
||||
public virtual DbSet<ViewCountPerson> ViewCountsPerson { get; set; }
|
||||
public virtual DbSet<ViewCountMedia> ViewCountsMedia { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROTECTED METHODS
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseNpgsql("name=Default");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetAssembly(typeof(AccountConfiguration)));
|
||||
CreateRootUser(modelBuilder);
|
||||
}
|
||||
|
||||
protected void CreateRootUser(ModelBuilder modelBuilder)
|
||||
{
|
||||
IConfigurationSection configuration = this.GetService<IConfiguration>().GetSection("RootUser");
|
||||
|
||||
string leftSalt = StringExtensions.CreateRandom(20);
|
||||
string rightSalt = StringExtensions.CreateRandom(20);
|
||||
byte[] hash = SHA512.HashData(Encoding.UTF8.GetBytes($"{leftSalt}{configuration["Password"]}{rightSalt}"));
|
||||
|
||||
modelBuilder.Entity<Account>().HasData(new Account
|
||||
{
|
||||
Id = 1,
|
||||
Username = configuration["Username"]!,
|
||||
Email = configuration["Email"]!,
|
||||
Password = hash,
|
||||
LeftSalt = leftSalt,
|
||||
RightSalt = rightSalt,
|
||||
IsAdmin = true,
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user