Creation des Challonges a partir des Event WordPress

This commit is contained in:
2018-10-08 23:33:18 +02:00
parent 70b5ea54f7
commit 39075051b2
10 changed files with 264 additions and 114 deletions

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using LaDOSE.Entity.Wordpress;
using Microsoft.EntityFrameworkCore;
namespace LaDOSE.Entity.Context
{
@@ -8,6 +9,14 @@ namespace LaDOSE.Entity.Context
public DbSet<ApplicationUser> ApplicationUser { get; set; }
public DbSet<Season> Season { get; set; }
public DbSet<Event> Event { get; set; }
#region WordPress
public DbSet<WPUser> WPUser { get; set; }
public DbSet<WPEvent> WPEvent { get; set; }
public DbSet<WPBooking> WPBooking { get; set; }
#endregion
public DbSet<SeasonGame> SeasonGame { get; set; }
public DbSet<EventGame> EventGame { get; set; }
@@ -20,17 +29,18 @@ namespace LaDOSE.Entity.Context
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<SeasonGame>()
.HasKey(t => new { t.SeasonId, t.GameId });
modelBuilder.Entity<EventGame>()
.HasKey(t => new { t.EventId, t.GameId });
modelBuilder.Entity<Event>()
.HasOne(s => s.Season)
.WithMany(p => p.Event)
.HasForeignKey(fk => fk.SeasonId);
#region SeasonGame
modelBuilder.Entity<SeasonGame>()
.HasKey(t => new { t.SeasonId, t.GameId });
modelBuilder.Entity<SeasonGame>()
.HasOne(pt => pt.Season)
@@ -41,7 +51,12 @@ namespace LaDOSE.Entity.Context
.HasOne(pt => pt.Game)
.WithMany(p => p.Seasons)
.HasForeignKey(pt => pt.GameId);
#endregion
#region EventGame
modelBuilder.Entity<EventGame>()
.HasKey(t => new { t.EventId, t.GameId });
modelBuilder.Entity<EventGame>()
.HasOne(pt => pt.Event)
@@ -52,6 +67,23 @@ namespace LaDOSE.Entity.Context
.HasOne(pt => pt.Game)
.WithMany(p => p.Events)
.HasForeignKey(pt => pt.GameId);
#endregion
#region WordPress WPBooking
modelBuilder.Entity<WPBooking>()
.HasKey(t => new { t.WPEventId, t.WPUserId });
modelBuilder.Entity<WPBooking>()
.HasOne(pt => pt.WPEvent)
.WithMany(p => p.WPBookings)
.HasForeignKey(pt => pt.WPEventId);
modelBuilder.Entity<WPBooking>()
.HasOne(pt => pt.WPUser)
.WithMany(p => p.WPBookings)
.HasForeignKey(pt => pt.WPUserId);
#endregion
}
}

View File

@@ -0,0 +1,16 @@
namespace LaDOSE.Entity.Wordpress
{
public class WPBooking
{
//# WPEventId, WPUserId, Message, Meta
public int WPEventId { get; set; }
public WPEvent WPEvent { get; set; }
public int WPUserId { get; set; }
public WPUser WPUser { get; set; }
public string Message { get; set; }
public string Meta { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace LaDOSE.Entity.Wordpress
{
public class WPEvent
{
[Key]
// Id, Name, Slug, Date
public int Id { get; set; }
public string Name { get; set; }
public string Slug { get; set; }
public string Date { get; set; }
public virtual IEnumerable<WPBooking> WPBookings { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace LaDOSE.Entity.Wordpress
{
public class WPUser
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string WPUserId { get; set; }
public string WPMail { get; set; }
public virtual IEnumerable<WPBooking> WPBookings { get; set; }
}
}