model changes
This commit is contained in:
56
WatchIt.Database/WatchIt.Database.Model/Common/Country.cs
Normal file
56
WatchIt.Database/WatchIt.Database.Model/Common/Country.cs
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
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.Genre
|
||||
namespace WatchIt.Database.Model.Common
|
||||
{
|
||||
public class Genre : IEntity<Genre>
|
||||
{
|
||||
@@ -21,8 +24,8 @@ namespace WatchIt.Database.Model.Genre
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public ICollection<GenreMedia> GenreMedia { get; set; }
|
||||
public ICollection<Media.Media> Media { get; set; }
|
||||
public IEnumerable<MediaGenre> MediaGenres { get; set; }
|
||||
public IEnumerable<Media.Media> Media { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -48,15 +51,10 @@ namespace WatchIt.Database.Model.Genre
|
||||
// Navigation
|
||||
builder.HasMany(x => x.Media)
|
||||
.WithMany(x => x.Genres)
|
||||
.UsingEntity<GenreMedia>();
|
||||
.UsingEntity<MediaGenre>();
|
||||
}
|
||||
|
||||
static IEnumerable<Genre> IEntity<Genre>.InsertData() => new List<Genre>
|
||||
{
|
||||
new Genre { Id = 1, Name = "Comedy" },
|
||||
new Genre { Id = 2, Name = "Thriller" },
|
||||
new Genre { Id = 3, Name = "Horror" },
|
||||
};
|
||||
static IEnumerable<Genre> IEntity<Genre>.InsertData() => DataReader.Read<Genre>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Account;
|
||||
using WatchIt.Database.Model.Genre;
|
||||
using WatchIt.Database.Model.Common;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
@@ -28,9 +28,11 @@ namespace WatchIt.Database.Model.Media
|
||||
#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; }
|
||||
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; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -68,7 +70,10 @@ namespace WatchIt.Database.Model.Media
|
||||
// Navigation
|
||||
builder.HasMany(x => x.Genres)
|
||||
.WithMany(x => x.Media)
|
||||
.UsingEntity<GenreMedia>();
|
||||
.UsingEntity<MediaGenre>();
|
||||
builder.HasMany(x => x.ProductionCountries)
|
||||
.WithMany(x => x.MediaProduction)
|
||||
.UsingEntity<MediaProductionCountry>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -4,11 +4,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Common;
|
||||
|
||||
namespace WatchIt.Database.Model.Genre
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class GenreMedia : IEntity<GenreMedia>
|
||||
public class MediaGenre : IEntity<MediaGenre>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace WatchIt.Database.Model.Genre
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media.Media Media { get; set; }
|
||||
public Media Media { get; set; }
|
||||
public Genre Genre { get; set; }
|
||||
|
||||
#endregion
|
||||
@@ -30,17 +30,17 @@ namespace WatchIt.Database.Model.Genre
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<GenreMedia>.Build(EntityTypeBuilder<GenreMedia> builder)
|
||||
static void IEntity<MediaGenre>.Build(EntityTypeBuilder<MediaGenre> builder)
|
||||
{
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.GenreMedia)
|
||||
.WithMany(x => x.MediaGenres)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Genre)
|
||||
.WithMany(x => x.GenreMedia)
|
||||
.WithMany(x => x.MediaGenres)
|
||||
.HasForeignKey(x => x.GenreId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.GenreId)
|
||||
@@ -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.Common;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
public class MediaProductionCountry : IEntity<MediaProductionCountry>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long MediaId { get; set; }
|
||||
public short CountryId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media Media { get; set; }
|
||||
public Country Country { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<MediaProductionCountry>.Build(EntityTypeBuilder<MediaProductionCountry> builder)
|
||||
{
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.MediaProductionCountries)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Country)
|
||||
.WithMany(x => x.MediaProductionCountries)
|
||||
.HasForeignKey(x => x.CountryId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.CountryId)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace WatchIt.Database.Model.Media
|
||||
#region NAVIGATION
|
||||
|
||||
public Media Media { get; set; }
|
||||
public ICollection<MediaSeriesSeason> MediaSeriesSeasons { get; set; }
|
||||
public IEnumerable<MediaSeriesSeason> MediaSeriesSeasons { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace WatchIt.Database.Model.Media
|
||||
#region NAVIGATION
|
||||
|
||||
public MediaSeries MediaSeries { get; set; }
|
||||
public ICollection<MediaSeriesEpisode> MediaSeriesEpisodes { get; set; }
|
||||
public IEnumerable<MediaSeriesEpisode> MediaSeriesEpisodes { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -13,4 +13,8 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WatchIt.Database.DataSeeding\WatchIt.Database.DataSeeding.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user