Creation des Challonges a partir des Event WordPress
This commit is contained in:
@@ -33,10 +33,10 @@ namespace LaDOSE.Api.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("Generate/{dto}")]
|
[HttpGet("Generate/{eventId}/{wpEventId}")]
|
||||||
public bool GenerateChallonge(int dto)
|
public bool GenerateChallonge(int eventId, int wpEventId)
|
||||||
{
|
{
|
||||||
return _eventService.CreateChallonge(dto);
|
return _eventService.CreateChallonge(eventId, wpEventId);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using LaDOSE.Entity.Wordpress;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace LaDOSE.Entity.Context
|
namespace LaDOSE.Entity.Context
|
||||||
{
|
{
|
||||||
@@ -8,6 +9,14 @@ namespace LaDOSE.Entity.Context
|
|||||||
public DbSet<ApplicationUser> ApplicationUser { get; set; }
|
public DbSet<ApplicationUser> ApplicationUser { get; set; }
|
||||||
public DbSet<Season> Season { get; set; }
|
public DbSet<Season> Season { get; set; }
|
||||||
public DbSet<Event> Event { 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<SeasonGame> SeasonGame { get; set; }
|
||||||
public DbSet<EventGame> EventGame { get; set; }
|
public DbSet<EventGame> EventGame { get; set; }
|
||||||
|
|
||||||
@@ -20,10 +29,8 @@ namespace LaDOSE.Entity.Context
|
|||||||
|
|
||||||
|
|
||||||
base.OnModelCreating(modelBuilder);
|
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>()
|
modelBuilder.Entity<Event>()
|
||||||
.HasOne(s => s.Season)
|
.HasOne(s => s.Season)
|
||||||
@@ -31,6 +38,9 @@ namespace LaDOSE.Entity.Context
|
|||||||
.HasForeignKey(fk => fk.SeasonId);
|
.HasForeignKey(fk => fk.SeasonId);
|
||||||
|
|
||||||
|
|
||||||
|
#region SeasonGame
|
||||||
|
modelBuilder.Entity<SeasonGame>()
|
||||||
|
.HasKey(t => new { t.SeasonId, t.GameId });
|
||||||
|
|
||||||
modelBuilder.Entity<SeasonGame>()
|
modelBuilder.Entity<SeasonGame>()
|
||||||
.HasOne(pt => pt.Season)
|
.HasOne(pt => pt.Season)
|
||||||
@@ -41,7 +51,12 @@ namespace LaDOSE.Entity.Context
|
|||||||
.HasOne(pt => pt.Game)
|
.HasOne(pt => pt.Game)
|
||||||
.WithMany(p => p.Seasons)
|
.WithMany(p => p.Seasons)
|
||||||
.HasForeignKey(pt => pt.GameId);
|
.HasForeignKey(pt => pt.GameId);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region EventGame
|
||||||
|
|
||||||
|
modelBuilder.Entity<EventGame>()
|
||||||
|
.HasKey(t => new { t.EventId, t.GameId });
|
||||||
|
|
||||||
modelBuilder.Entity<EventGame>()
|
modelBuilder.Entity<EventGame>()
|
||||||
.HasOne(pt => pt.Event)
|
.HasOne(pt => pt.Event)
|
||||||
@@ -52,6 +67,23 @@ namespace LaDOSE.Entity.Context
|
|||||||
.HasOne(pt => pt.Game)
|
.HasOne(pt => pt.Game)
|
||||||
.WithMany(p => p.Events)
|
.WithMany(p => p.Events)
|
||||||
.HasForeignKey(pt => pt.GameId);
|
.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
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
LaDOSE.Src/LaDOSE.Entity/Wordpress/WPBooking.cs
Normal file
16
LaDOSE.Src/LaDOSE.Entity/Wordpress/WPBooking.cs
Normal 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; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
17
LaDOSE.Src/LaDOSE.Entity/Wordpress/WPEvent.cs
Normal file
17
LaDOSE.Src/LaDOSE.Entity/Wordpress/WPEvent.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
15
LaDOSE.Src/LaDOSE.Entity/Wordpress/WPUser.cs
Normal file
15
LaDOSE.Src/LaDOSE.Entity/Wordpress/WPUser.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,5 +9,6 @@ namespace LaDOSE.Business.Interface
|
|||||||
Task<Boolean> GetLastTournament();
|
Task<Boolean> GetLastTournament();
|
||||||
string GetLastTournamentMessage();
|
string GetLastTournamentMessage();
|
||||||
Task<TournamentResult> CreateTournament(string name, string url);
|
Task<TournamentResult> CreateTournament(string name, string url);
|
||||||
|
Task<ParticipantResult> AddPlayer(int tournamentId, string userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,6 @@ namespace LaDOSE.Business.Interface
|
|||||||
{
|
{
|
||||||
public interface IEventService : IBaseService<Event>
|
public interface IEventService : IBaseService<Event>
|
||||||
{
|
{
|
||||||
bool CreateChallonge(int dto);
|
bool CreateChallonge(int eventId, int wpEventId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChallongeCSharpDriver;
|
using ChallongeCSharpDriver;
|
||||||
using ChallongeCSharpDriver.Caller;
|
using ChallongeCSharpDriver.Caller;
|
||||||
|
using ChallongeCSharpDriver.Core.Objects;
|
||||||
using ChallongeCSharpDriver.Core.Queries;
|
using ChallongeCSharpDriver.Core.Queries;
|
||||||
using ChallongeCSharpDriver.Core.Results;
|
using ChallongeCSharpDriver.Core.Results;
|
||||||
using LaDOSE.Business.Interface;
|
using LaDOSE.Business.Interface;
|
||||||
@@ -36,6 +37,14 @@ namespace LaDOSE.Business.Provider
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ParticipantResult> AddPlayer(int tournamentId, string userName)
|
||||||
|
{
|
||||||
|
var p = new ParticipantEntry(userName);
|
||||||
|
var result = await new AddParticipantQuery(tournamentId, p).call(ApiCaller);
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<Boolean> GetLastTournament()
|
public async Task<Boolean> GetLastTournament()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -33,9 +33,13 @@ namespace LaDOSE.Business.Service
|
|||||||
return eventAdded.Entity;
|
return eventAdded.Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CreateChallonge(int dto)
|
public bool CreateChallonge(int eventId,int wpEventId)
|
||||||
{
|
{
|
||||||
var currentEvent = _context.Event.Include(e=>e.Games).ThenInclude(e=>e.Game).FirstOrDefault(e=>e.Id == dto);
|
var currentEvent = _context.Event.Include(e=>e.Games).ThenInclude(e=>e.Game).FirstOrDefault(e=>e.Id == eventId);
|
||||||
|
var currentWpEvent = _context.WPEvent.Include(e => e.WPBookings).ThenInclude(e => e.WPUser).Where(e=>e.Id == wpEventId);
|
||||||
|
var users = currentWpEvent.SelectMany(e => e.WPBookings.Select(u => u.WPUser));
|
||||||
|
|
||||||
|
var userNames = users.Select(e => e.Name).Distinct().ToList();
|
||||||
if (currentEvent != null)
|
if (currentEvent != null)
|
||||||
{
|
{
|
||||||
var games = currentEvent.Games.Select(e => e.Game);
|
var games = currentEvent.Games.Select(e => e.Game);
|
||||||
@@ -48,6 +52,19 @@ namespace LaDOSE.Business.Service
|
|||||||
var eventGame = currentEvent.Games.FirstOrDefault(e => e.GameId == game.Id);
|
var eventGame = currentEvent.Games.FirstOrDefault(e => e.GameId == game.Id);
|
||||||
eventGame.ChallongeId = tournament.id;
|
eventGame.ChallongeId = tournament.id;
|
||||||
eventGame.ChallongeUrl = tournament.url;
|
eventGame.ChallongeUrl = tournament.url;
|
||||||
|
foreach (var userName in userNames)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_challongeProvider.AddPlayer(tournament.id, userName);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Erreur d ajout sur {userName}" );
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
_context.Entry(eventGame).State = EntityState.Modified;
|
_context.Entry(eventGame).State = EntityState.Modified;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,169 +1,212 @@
|
|||||||
-- phpMyAdmin SQL Dump
|
-- MySQL dump 10.13 Distrib 5.7.12, for Win64 (x86_64)
|
||||||
-- version 4.6.4
|
|
||||||
-- https://www.phpmyadmin.net/
|
|
||||||
--
|
--
|
||||||
-- Host: localhost
|
-- Host: api.ladose.net Database: ladoseapi
|
||||||
-- Generation Time: Oct 06, 2018 at 10:12 PM
|
-- ------------------------------------------------------
|
||||||
-- Server version: 5.6.40-log
|
-- Server version 5.6.40-log
|
||||||
-- PHP Version: 7.1.18
|
|
||||||
|
|
||||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
|
||||||
SET time_zone = "+00:00";
|
|
||||||
|
|
||||||
|
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||||
/*!40101 SET NAMES utf8mb4 */;
|
/*!40101 SET NAMES utf8 */;
|
||||||
|
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||||
--
|
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||||
-- Database: `ladoseapi`
|
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||||
--
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||||
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||||
-- --------------------------------------------------------
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `ApplicationUser`
|
-- Table structure for table `ApplicationUser`
|
||||||
--
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `ApplicationUser`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
CREATE TABLE `ApplicationUser` (
|
CREATE TABLE `ApplicationUser` (
|
||||||
`Id` int(11) NOT NULL,
|
`Id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`FirstName` varchar(45) DEFAULT NULL,
|
`FirstName` varchar(45) DEFAULT NULL,
|
||||||
`LastName` varchar(45) DEFAULT NULL,
|
`LastName` varchar(45) DEFAULT NULL,
|
||||||
`UserName` varchar(45) DEFAULT NULL,
|
`UserName` varchar(45) DEFAULT NULL,
|
||||||
`PasswordHash` blob,
|
`PasswordHash` blob,
|
||||||
`PasswordSalt` blob
|
`PasswordSalt` blob,
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
PRIMARY KEY (`Id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;
|
||||||
-- --------------------------------------------------------
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `Event`
|
-- Table structure for table `Event`
|
||||||
--
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `Event`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
CREATE TABLE `Event` (
|
CREATE TABLE `Event` (
|
||||||
`Id` int(11) NOT NULL,
|
`Id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`Name` varchar(255) NOT NULL,
|
`Name` varchar(255) NOT NULL,
|
||||||
`Date` datetime NOT NULL,
|
`Date` datetime NOT NULL,
|
||||||
`SeasonId` int(11) NOT NULL,
|
`SeasonId` int(11) NOT NULL,
|
||||||
`Ranking` tinyint(4) DEFAULT NULL
|
`Ranking` tinyint(4) DEFAULT NULL,
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
PRIMARY KEY (`Id`),
|
||||||
|
KEY `SeasonPK_idx` (`SeasonId`),
|
||||||
|
CONSTRAINT `SeasonsPK` FOREIGN KEY (`SeasonId`) REFERENCES `Season` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
--
|
||||||
|
-- Table structure for table `EventGame`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `EventGame`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `EventGame` (
|
||||||
|
`EventId` int(11) NOT NULL,
|
||||||
|
`GameId` int(11) NOT NULL,
|
||||||
|
`ChallongeId` int(11) DEFAULT NULL,
|
||||||
|
`ChallongeUrl` varchar(250) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`EventId`,`GameId`),
|
||||||
|
KEY `GamePK_idx` (`GameId`),
|
||||||
|
CONSTRAINT `EventGame_EventPK` FOREIGN KEY (`EventId`) REFERENCES `Event` (`Id`),
|
||||||
|
CONSTRAINT `EventGame_GamePk` FOREIGN KEY (`GameId`) REFERENCES `Game` (`Id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `Game`
|
-- Table structure for table `Game`
|
||||||
--
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `Game`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
CREATE TABLE `Game` (
|
CREATE TABLE `Game` (
|
||||||
`Id` int(11) NOT NULL,
|
`Id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`Name` varchar(45) CHARACTER SET utf8 DEFAULT NULL,
|
`Name` varchar(45) CHARACTER SET utf8 DEFAULT NULL,
|
||||||
`ImgUrl` varchar(255) CHARACTER SET utf8 DEFAULT NULL
|
`ImgUrl` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
PRIMARY KEY (`Id`),
|
||||||
|
UNIQUE KEY `name_UNIQUE` (`Name`)
|
||||||
-- --------------------------------------------------------
|
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `Season`
|
-- Table structure for table `Season`
|
||||||
--
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `Season`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
CREATE TABLE `Season` (
|
CREATE TABLE `Season` (
|
||||||
`Id` int(11) NOT NULL,
|
`Id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`Name` varchar(45) DEFAULT NULL,
|
`Name` varchar(45) DEFAULT NULL,
|
||||||
`StartDate` datetime DEFAULT NULL,
|
`StartDate` datetime DEFAULT NULL,
|
||||||
`EndDate` datetime DEFAULT NULL
|
`EndDate` datetime DEFAULT NULL,
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
PRIMARY KEY (`Id`),
|
||||||
|
UNIQUE KEY `Name_UNIQUE` (`Name`)
|
||||||
-- --------------------------------------------------------
|
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `SeasonGame`
|
-- Table structure for table `SeasonGame`
|
||||||
--
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `SeasonGame`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
CREATE TABLE `SeasonGame` (
|
CREATE TABLE `SeasonGame` (
|
||||||
`SeasonId` int(11) NOT NULL,
|
`SeasonId` int(11) NOT NULL,
|
||||||
`GameId` int(11) NOT NULL
|
`GameId` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`SeasonId`,`GameId`),
|
||||||
|
KEY `GamePK_idx` (`GameId`),
|
||||||
|
CONSTRAINT `GamePK` FOREIGN KEY (`GameId`) REFERENCES `Game` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT `SeasonPK` FOREIGN KEY (`SeasonId`) REFERENCES `Season` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Indexes for dumped tables
|
-- Table structure for table `WPBooking`
|
||||||
--
|
--
|
||||||
|
|
||||||
--
|
DROP TABLE IF EXISTS `WPBooking`;
|
||||||
-- Indexes for table `ApplicationUser`
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
--
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
ALTER TABLE `ApplicationUser`
|
CREATE TABLE `WPBooking` (
|
||||||
ADD PRIMARY KEY (`Id`);
|
`WPEventId` int(11) DEFAULT NULL,
|
||||||
|
`WPUserId` int(11) DEFAULT NULL,
|
||||||
|
`Message` varchar(5000) DEFAULT NULL,
|
||||||
|
`Meta` varchar(5000) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Indexes for table `Event`
|
-- Table structure for table `WPEvent`
|
||||||
--
|
|
||||||
ALTER TABLE `Event`
|
|
||||||
ADD PRIMARY KEY (`Id`),
|
|
||||||
ADD KEY `SeasonPK_idx` (`SeasonId`);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Indexes for table `Game`
|
|
||||||
--
|
|
||||||
ALTER TABLE `Game`
|
|
||||||
ADD PRIMARY KEY (`Id`),
|
|
||||||
ADD UNIQUE KEY `name_UNIQUE` (`Name`);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Indexes for table `Season`
|
|
||||||
--
|
|
||||||
ALTER TABLE `Season`
|
|
||||||
ADD PRIMARY KEY (`Id`),
|
|
||||||
ADD UNIQUE KEY `Name_UNIQUE` (`Name`);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Indexes for table `SeasonGame`
|
|
||||||
--
|
|
||||||
ALTER TABLE `SeasonGame`
|
|
||||||
ADD PRIMARY KEY (`SeasonId`,`GameId`),
|
|
||||||
ADD KEY `GamePK_idx` (`GameId`);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- AUTO_INCREMENT for dumped tables
|
|
||||||
--
|
--
|
||||||
|
|
||||||
--
|
DROP TABLE IF EXISTS `WPEvent`;
|
||||||
-- AUTO_INCREMENT for table `ApplicationUser`
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
--
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
ALTER TABLE `ApplicationUser`
|
CREATE TABLE `WPEvent` (
|
||||||
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
|
`Id` int(11) NOT NULL,
|
||||||
--
|
`Name` varchar(255) DEFAULT NULL,
|
||||||
-- AUTO_INCREMENT for table `Event`
|
`Slug` varchar(255) DEFAULT NULL,
|
||||||
--
|
`Date` date DEFAULT NULL
|
||||||
ALTER TABLE `Event`
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
--
|
|
||||||
-- AUTO_INCREMENT for table `Game`
|
|
||||||
--
|
|
||||||
ALTER TABLE `Game`
|
|
||||||
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
|
||||||
--
|
|
||||||
-- AUTO_INCREMENT for table `Season`
|
|
||||||
--
|
|
||||||
ALTER TABLE `Season`
|
|
||||||
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
|
||||||
--
|
|
||||||
-- Constraints for dumped tables
|
|
||||||
--
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Constraints for table `Event`
|
-- Table structure for table `WPUser`
|
||||||
--
|
--
|
||||||
ALTER TABLE `Event`
|
|
||||||
ADD CONSTRAINT `SeasonsPK` FOREIGN KEY (`SeasonId`) REFERENCES `Season` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
|
DROP TABLE IF EXISTS `WPUser`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `WPUser` (
|
||||||
|
`Id` int(11) NOT NULL,
|
||||||
|
`Name` varchar(45) DEFAULT NULL,
|
||||||
|
`WPUserLogin` varchar(45) DEFAULT NULL,
|
||||||
|
`WPMail` varchar(45) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Constraints for table `SeasonGame`
|
-- Dumping routines for database 'ladoseapi'
|
||||||
--
|
--
|
||||||
ALTER TABLE `SeasonGame`
|
/*!50003 DROP PROCEDURE IF EXISTS `ImportEvent` */;
|
||||||
ADD CONSTRAINT `GamePK` FOREIGN KEY (`GameId`) REFERENCES `Game` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||||
ADD CONSTRAINT `SeasonPK` FOREIGN KEY (`SeasonId`) REFERENCES `Season` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
|
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
||||||
|
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
|
||||||
|
/*!50003 SET character_set_client = utf8 */ ;
|
||||||
|
/*!50003 SET character_set_results = utf8 */ ;
|
||||||
|
/*!50003 SET collation_connection = utf8_general_ci */ ;
|
||||||
|
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||||
|
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
|
||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`ladoseapi`@`%` PROCEDURE `ImportEvent`()
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO WPEvent (Id, Name,Slug,Date )
|
||||||
|
select event_id, event_name,event_slug, event_start_date from ladose.wp_em_events
|
||||||
|
where event_id not in (select Id from WPEvent);
|
||||||
|
|
||||||
|
INSERT INTO WPUser (Id, Name, WPUSerLogin, WPMail)
|
||||||
|
select ID, display_name, user_login , user_email from ladose.wp_users
|
||||||
|
where ID not in (select Id from WPUser);
|
||||||
|
|
||||||
|
INSERT INTO WPBooking (WPEventId, WPUserId, Message, Meta)
|
||||||
|
select event_id, person_id, booking_comment , booking_meta from ladose.wp_em_bookings
|
||||||
|
where (event_id , person_id) not in (select WPEventId,WPUserId from WPBooking);
|
||||||
|
END ;;
|
||||||
|
DELIMITER ;
|
||||||
|
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||||
|
/*!50003 SET character_set_client = @saved_cs_client */ ;
|
||||||
|
/*!50003 SET character_set_results = @saved_cs_results */ ;
|
||||||
|
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||||
|
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||||
|
|
||||||
|
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||||
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||||
|
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
|
-- Dump completed on 2018-10-08 23:31:28
|
||||||
|
i
|
||||||
|
|||||||
Reference in New Issue
Block a user