Person models added

This commit is contained in:
2024-03-20 00:34:47 +01:00
Unverified
parent 0d777344a9
commit a5b7efdff6
17 changed files with 3367 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ using System.Text;
using System.Threading.Tasks;
using WatchIt.Database.Model.Account;
using WatchIt.Database.Model.Common;
using WatchIt.Database.Model.Person;
namespace WatchIt.Database.Model.Media
{
@@ -28,12 +29,19 @@ namespace WatchIt.Database.Model.Media
#region NAVIGATION
public MediaPosterImage? MediaPosterImage { get; set; }
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<MediaProductionCountry> MediaProductionCountries { get; set; }
public IEnumerable<Country> ProductionCountries { get; set; }
public IEnumerable<PersonActorRole> PersonActorRoles { get; set; }
public IEnumerable<PersonCreatorRole> PersonCreatorRoles { get; set; }
#endregion

View File

@@ -0,0 +1,69 @@
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 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 Guid? PersonPhotoId { get; set; }
#endregion
#region NAVIGATION
public PersonPhotoImage? PersonPhoto { get; set; }
public IEnumerable<PersonActorRole> PersonActorRoles { get; set; }
public IEnumerable<PersonCreatorRole> PersonCreatorRoles { 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.PersonPhoto)
.WithOne(x => x.Person)
.HasForeignKey<Person>(e => e.PersonPhotoId);
builder.Property(x => x.PersonPhotoId);
}
#endregion
}
}

View File

@@ -0,0 +1,69 @@
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.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; }
#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
}
}

View File

@@ -0,0 +1,41 @@
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
}
}

View File

@@ -0,0 +1,67 @@
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.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; }
#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
}
}

View File

@@ -0,0 +1,41 @@
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
}
}

View File

@@ -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;
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
}
}