2024-03-18 00:14:08 +01:00
|
|
|
|
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;
|
2024-03-19 17:25:13 +01:00
|
|
|
|
using WatchIt.Database.Model.Common;
|
2024-03-18 00:14:08 +01:00
|
|
|
|
|
|
|
|
|
|
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; }
|
2024-03-19 17:25:13 +01:00
|
|
|
|
public IEnumerable<MediaPhotoImage> MediaPhotoImages { get; set; }
|
|
|
|
|
|
public IEnumerable<MediaGenre> MediaGenres { get; set; }
|
|
|
|
|
|
public IEnumerable<MediaProductionCountry> MediaProductionCountries { get; set; }
|
|
|
|
|
|
public IEnumerable<Genre> Genres { get; set; }
|
|
|
|
|
|
public IEnumerable<Country> ProductionCountries { get; set; }
|
2024-03-18 00:14:08 +01:00
|
|
|
|
|
|
|
|
|
|
#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)
|
2024-03-19 17:25:13 +01:00
|
|
|
|
.UsingEntity<MediaGenre>();
|
|
|
|
|
|
builder.HasMany(x => x.ProductionCountries)
|
|
|
|
|
|
.WithMany(x => x.MediaProduction)
|
|
|
|
|
|
.UsingEntity<MediaProductionCountry>();
|
2024-03-18 00:14:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|