Get playsessions on import as separate request
This commit is contained in:
parent
a3d9e92240
commit
c6c372ffd3
3 changed files with 69 additions and 2 deletions
|
|
@ -249,7 +249,7 @@ namespace LANCommander.Launcher.Services
|
|||
})
|
||||
.ImportAsync();
|
||||
|
||||
await DatabaseContext.BulkImport<PlaySession, SDK.Models.PlaySession>()
|
||||
/*await DatabaseContext.BulkImport<PlaySession, SDK.Models.PlaySession>()
|
||||
.SetTarget(localGame.PlaySessions)
|
||||
.UseSource(game.PlaySessions)
|
||||
.Include(p => p.Game)
|
||||
|
|
@ -261,7 +261,7 @@ namespace LANCommander.Launcher.Services
|
|||
t.UserId = s.UserId;
|
||||
})
|
||||
.AsNoRemove()
|
||||
.ImportAsync();
|
||||
.ImportAsync();*/
|
||||
|
||||
var importedMedia = await DatabaseContext.BulkImport<Media, SDK.Models.Media>()
|
||||
.SetTarget(localGame.Media)
|
||||
|
|
@ -319,6 +319,22 @@ namespace LANCommander.Launcher.Services
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
var playSessions = await Client.PlaySessions.GetAsync(localGame.Id);
|
||||
|
||||
await DatabaseContext.BulkImport<PlaySession, SDK.Models.PlaySession>()
|
||||
.SetTarget(localGame.PlaySessions)
|
||||
.UseSource(playSessions)
|
||||
.Include(p => p.Game)
|
||||
.Assign((t, s) =>
|
||||
{
|
||||
t.Game = localGame;
|
||||
t.Start = s.Start;
|
||||
t.End = s.End;
|
||||
t.UserId = s.UserId;
|
||||
})
|
||||
.AsNoRemove()
|
||||
.ImportAsync();
|
||||
|
||||
localGame = await GameService.UpdateAsync(localGame);
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace LANCommander.SDK
|
|||
public readonly IssueService Issues;
|
||||
public readonly LobbyService Lobbies;
|
||||
public readonly ServerService Servers;
|
||||
public readonly PlaySessionService PlaySessions;
|
||||
|
||||
private Settings _Settings { get; set; }
|
||||
public Settings Settings
|
||||
|
|
@ -75,6 +76,7 @@ namespace LANCommander.SDK
|
|||
Issues = new IssueService(this);
|
||||
Lobbies = new LobbyService(this);
|
||||
Servers = new ServerService(this);
|
||||
PlaySessions = new PlaySessionService(this);
|
||||
|
||||
BaseCmdlet.Client = this;
|
||||
|
||||
|
|
@ -99,6 +101,7 @@ namespace LANCommander.SDK
|
|||
Issues = new IssueService(this);
|
||||
Lobbies = new LobbyService(this, logger);
|
||||
Servers = new ServerService(this, logger);
|
||||
PlaySessions = new PlaySessionService(this, logger);
|
||||
|
||||
BaseCmdlet.Client = this;
|
||||
|
||||
|
|
|
|||
48
LANCommander.SDK/Services/PlaySessionService.cs
Normal file
48
LANCommander.SDK/Services/PlaySessionService.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using LANCommander.SDK.Enums;
|
||||
using LANCommander.SDK.Extensions;
|
||||
using LANCommander.SDK.Helpers;
|
||||
using LANCommander.SDK.Models;
|
||||
using LANCommander.SDK.PowerShell;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RestSharp;
|
||||
using Semver;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Readers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LANCommander.SDK.Services
|
||||
{
|
||||
public class PlaySessionService
|
||||
{
|
||||
private readonly ILogger Logger;
|
||||
private Client Client { get; set; }
|
||||
|
||||
public PlaySessionService(Client client)
|
||||
{
|
||||
Client = client;
|
||||
}
|
||||
|
||||
public PlaySessionService(Client client, ILogger logger)
|
||||
{
|
||||
Client = client;
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<EntityReference>> GetAsync()
|
||||
{
|
||||
return await Client.GetRequestAsync<IEnumerable<EntityReference>>("/api/PlaySessions");
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<PlaySession>> GetAsync(Guid gameId)
|
||||
{
|
||||
return await Client.PostRequestAsync<IEnumerable<PlaySession>>($"/api/PlaySessions/{gameId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue