2024-03-17 14:26:03 +01:00
|
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
2024-03-19 17:25:13 +01:00
|
|
|
|
using Newtonsoft.Json;
|
2024-03-17 14:26:03 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2024-03-19 17:25:13 +01:00
|
|
|
|
using WatchIt.Database.DataSeeding;
|
|
|
|
|
|
using WatchIt.Database.Model.Media;
|
2024-03-17 14:26:03 +01:00
|
|
|
|
|
2024-03-19 17:25:13 +01:00
|
|
|
|
namespace WatchIt.Database.Model.Common
|
2024-03-17 14:26:03 +01:00
|
|
|
|
{
|
|
|
|
|
|
public class Genre : IEntity<Genre>
|
|
|
|
|
|
{
|
|
|
|
|
|
#region PROPERTIES
|
|
|
|
|
|
|
|
|
|
|
|
public short Id { get; set; }
|
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
public string? Description { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-18 00:14:08 +01:00
|
|
|
|
#region NAVIGATION
|
|
|
|
|
|
|
2024-03-19 17:25:13 +01:00
|
|
|
|
public IEnumerable<MediaGenre> MediaGenres { get; set; }
|
|
|
|
|
|
public IEnumerable<Media.Media> Media { get; set; }
|
2024-03-18 00:14:08 +01:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-17 14:26:03 +01:00
|
|
|
|
#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);
|
2024-03-18 00:14:08 +01:00
|
|
|
|
|
|
|
|
|
|
// Navigation
|
|
|
|
|
|
builder.HasMany(x => x.Media)
|
|
|
|
|
|
.WithMany(x => x.Genres)
|
2024-03-19 17:25:13 +01:00
|
|
|
|
.UsingEntity<MediaGenre>();
|
2024-03-17 14:26:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-19 17:25:13 +01:00
|
|
|
|
static IEnumerable<Genre> IEntity<Genre>.InsertData() => DataReader.Read<Genre>();
|
2024-03-17 14:26:03 +01:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|