model changes

This commit is contained in:
2024-03-19 17:25:13 +01:00
Unverified
parent 6d1b30db47
commit 0d777344a9
30 changed files with 694 additions and 3283 deletions

View File

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

View File

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