2025-08-18 03:00:08 -05:00
|
|
|
|
using LANCommander.SDK.Models;
|
2024-10-31 01:54:34 -05:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2025-08-20 21:02:00 -05:00
|
|
|
|
using System.Linq;
|
2024-10-31 01:54:34 -05:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.SDK.Services
|
|
|
|
|
|
{
|
|
|
|
|
|
public class LibraryService
|
|
|
|
|
|
{
|
2025-08-18 03:02:49 -05:00
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
private readonly Client _client;
|
2024-10-31 01:54:34 -05:00
|
|
|
|
|
|
|
|
|
|
public LibraryService(Client client)
|
|
|
|
|
|
{
|
2025-08-18 03:02:49 -05:00
|
|
|
|
_client = client;
|
2024-10-31 01:54:34 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public LibraryService(Client client, ILogger logger)
|
|
|
|
|
|
{
|
2025-08-18 03:02:49 -05:00
|
|
|
|
_client = client;
|
|
|
|
|
|
_logger = logger;
|
2024-10-31 01:54:34 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-12 02:54:41 -06:00
|
|
|
|
public async Task<IEnumerable<EntityReference>> GetAsync()
|
2024-10-31 01:54:34 -05:00
|
|
|
|
{
|
2025-08-20 21:02:00 -05:00
|
|
|
|
var results = await _client.GetRequestAsync<IEnumerable<EntityReference>>("/api/Library");
|
|
|
|
|
|
|
|
|
|
|
|
return results ?? [];
|
2024-10-31 01:54:34 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<bool> AddToLibrary(Guid gameId)
|
|
|
|
|
|
{
|
2025-08-18 03:02:49 -05:00
|
|
|
|
return await _client.PostRequestAsync<bool>($"/api/Library/AddToLibrary/{gameId}");
|
2024-10-31 01:54:34 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<bool> RemoveFromLibrary(Guid gameId)
|
|
|
|
|
|
{
|
2025-08-18 03:02:49 -05:00
|
|
|
|
return await _client.PostRequestAsync<bool>($"/api/Library/RemoveFromLibrary/{gameId}");
|
2024-10-31 01:54:34 -05:00
|
|
|
|
}
|
2025-05-25 18:35:01 +02:00
|
|
|
|
|
|
|
|
|
|
public async Task<bool> RemoveFromLibrary(Guid gameId, Guid[] addonIds)
|
|
|
|
|
|
{
|
|
|
|
|
|
var requestBody = new GenericGuidsRequest { Guids = addonIds };
|
2025-08-18 03:02:49 -05:00
|
|
|
|
return await _client.PostRequestAsync<bool>($"/api/Library/RemoveFromLibrary/{gameId}/addons", requestBody);
|
2025-05-25 18:35:01 +02:00
|
|
|
|
}
|
2024-10-31 01:54:34 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|