new models
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Account
|
||||
{
|
||||
@@ -20,17 +21,14 @@ namespace WatchIt.Database.Model.Account
|
||||
public string Username { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Description { get; set; }
|
||||
public Guid AccountProfilePictureId { get; set; }
|
||||
|
||||
// BackgroundPicture key to MovieImages
|
||||
// public Guid BackgroundPicture { 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 DateTimeOffset CreationDate { get; set; }
|
||||
public DateTimeOffset LastActive { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime LastActive { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -38,7 +36,8 @@ namespace WatchIt.Database.Model.Account
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public AccountProfilePicture AccountProfilePicture { get; set; }
|
||||
public AccountProfilePicture? ProfilePicture { get; set; }
|
||||
public MediaPhotoImage? BackgroundPicture { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -65,10 +64,15 @@ namespace WatchIt.Database.Model.Account
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.HasOne(x => x.AccountProfilePicture)
|
||||
builder.HasOne(x => x.ProfilePicture)
|
||||
.WithOne(x => x.Account)
|
||||
.HasForeignKey<Account>(e => e.AccountProfilePictureId);
|
||||
builder.Property(x => x.AccountProfilePictureId);
|
||||
.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)
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace WatchIt.Database.Model.Account
|
||||
public Guid Id { get; set; }
|
||||
public byte[] Image { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
public DateTimeOffset UploadDate { get; set; }
|
||||
public DateTime UploadDate { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -19,6 +19,15 @@ namespace WatchIt.Database.Model.Genre
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public ICollection<GenreMedia> GenreMedia { get; set; }
|
||||
public ICollection<Media.Media> Media { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<Genre>.Build(EntityTypeBuilder<Genre> builder)
|
||||
@@ -35,6 +44,11 @@ namespace WatchIt.Database.Model.Genre
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.Media)
|
||||
.WithMany(x => x.Genres)
|
||||
.UsingEntity<GenreMedia>();
|
||||
}
|
||||
|
||||
static IEnumerable<Genre> IEntity<Genre>.InsertData() => new List<Genre>
|
||||
|
||||
52
WatchIt.Database/WatchIt.Database.Model/Genre/GenreMedia.cs
Normal file
52
WatchIt.Database/WatchIt.Database.Model/Genre/GenreMedia.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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.Genre
|
||||
{
|
||||
public class GenreMedia : IEntity<GenreMedia>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long MediaId { get; set; }
|
||||
public short GenreId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media.Media Media { get; set; }
|
||||
public Genre Genre { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<GenreMedia>.Build(EntityTypeBuilder<GenreMedia> builder)
|
||||
{
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.GenreMedia)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Genre)
|
||||
.WithMany(x => x.GenreMedia)
|
||||
.HasForeignKey(x => x.GenreId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.GenreId)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
76
WatchIt.Database/WatchIt.Database.Model/Media/Media.cs
Normal file
76
WatchIt.Database/WatchIt.Database.Model/Media/Media.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
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.Genre;
|
||||
|
||||
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 ICollection<MediaPhotoImage> MediaPhotoImages { get; set; }
|
||||
public ICollection<GenreMedia> GenreMedia { get; set; }
|
||||
public ICollection<Genre.Genre> Genres { 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<GenreMedia>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
50
WatchIt.Database/WatchIt.Database.Model/Media/MediaMovie.cs
Normal file
50
WatchIt.Database/WatchIt.Database.Model/Media/MediaMovie.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
49
WatchIt.Database/WatchIt.Database.Model/Media/MediaSeries.cs
Normal file
49
WatchIt.Database/WatchIt.Database.Model/Media/MediaSeries.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
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 ICollection<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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
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 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; }
|
||||
|
||||
#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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
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 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 ICollection<MediaSeriesEpisode> MediaSeriesEpisodes { 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user