new models
This commit is contained in:
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