Try to parse Php Serialized object.
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LaDOSE.Business.Helper;
|
||||
using LaDOSE.Business.Interface;
|
||||
using LaDOSE.Entity;
|
||||
using LaDOSE.Entity.Context;
|
||||
using LaDOSE.Entity.Wordpress;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LaDOSE.Business.Service
|
||||
@@ -33,6 +37,30 @@ namespace LaDOSE.Business.Service
|
||||
return eventAdded.Entity;
|
||||
}
|
||||
|
||||
public List<WPUser> GetBooking(int eventId, int wpEventId,Game game)
|
||||
{
|
||||
|
||||
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).ToList();
|
||||
List<WPBooking> bookings = currentWpEvent.SelectMany(e => e.WPBookings).ToList();
|
||||
List<WPUser> users = new List<WPUser>();
|
||||
foreach (var booking in bookings)
|
||||
{
|
||||
PhpSerializer p = new PhpSerializer();
|
||||
var b = p.Deserialize(booking.Meta);
|
||||
Hashtable Wpbook = b as Hashtable;
|
||||
Hashtable reg = Wpbook["registration"] as Hashtable;
|
||||
Hashtable reg2 = Wpbook["booking"] as Hashtable;
|
||||
if (reg2.ContainsKey(game.Name) && ((string)reg2[game.Name]) == "1")
|
||||
{
|
||||
booking.WPUser.WPBookings = null;
|
||||
users.Add(booking.WPUser);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return users;
|
||||
}
|
||||
public bool CreateChallonge(int eventId,int wpEventId)
|
||||
{
|
||||
var currentEvent = _context.Event.Include(e=>e.Games).ThenInclude(e=>e.Game).FirstOrDefault(e=>e.Id == eventId);
|
||||
|
||||
24
LaDOSE.Src/LaDOSE.Service/Service/UtilService.cs
Normal file
24
LaDOSE.Src/LaDOSE.Service/Service/UtilService.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using LaDOSE.Business.Interface;
|
||||
using LaDOSE.Entity.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LaDOSE.Business.Service
|
||||
{
|
||||
public class UtilService : IUtilService
|
||||
{
|
||||
private LaDOSEDbContext _context;
|
||||
|
||||
public UtilService(LaDOSEDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public bool UpdateBooking()
|
||||
{
|
||||
_context.Database.SetCommandTimeout(60);
|
||||
_context.Database.ExecuteSqlCommand("call ladoseapi.ImportEvent();");
|
||||
_context.Database.SetCommandTimeout(30);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user