This commit is contained in:
Michael Green
2024-12-06 16:48:20 +11:00
parent 173e49286b
commit 2303ab5ffc
6 changed files with 197 additions and 146 deletions

View File

@@ -46,11 +46,13 @@ namespace gaseous_server.Classes
long metadataMapId = (long)dt.Rows[0][0];
// create dummy game metadata item and capture id
sql = "INSERT INTO Game (SourceId, Name) VALUES (@sourceid, @name); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sql = "INSERT INTO Game (SourceId, Name, dateAdded, lastUpdated) VALUES (@sourceid, @name, @dateadded, @lastupdated); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
dbDict = new Dictionary<string, object>()
{
{ "@sourceid", HasheousClient.Models.MetadataSources.None },
{ "@name", name }
{ "@name", name },
{ "@dateadded", DateTime.UtcNow },
{ "@lastupdated", DateTime.UtcNow }
};
dt = db.ExecuteCMD(sql, dbDict);

View File

@@ -298,15 +298,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}")]
[Route("{MetadataMapId}")]
[ProducesResponseType(typeof(gaseous_server.Models.Game), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "5Minute")]
public async Task<ActionResult> Game(long GameId)
public async Task<ActionResult> Game(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
@@ -326,15 +327,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/alternativename")]
[Route("{MetadataMapId}/alternativename")]
[ProducesResponseType(typeof(List<AlternativeName>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameAlternativeNames(long GameId)
public async Task<ActionResult> GameAlternativeNames(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game.AlternativeNames != null)
{
@@ -359,15 +361,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/agerating")]
[Route("{MetadataMapId}/agerating")]
[ProducesResponseType(typeof(List<AgeRatings.GameAgeRating>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameAgeClassification(long GameId)
public async Task<ActionResult> GameAgeClassification(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game.AgeRatings != null)
{
@@ -392,15 +395,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/artwork")]
[Route("{MetadataMapId}/artwork")]
[ProducesResponseType(typeof(List<Artwork>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameArtwork(long GameId)
public async Task<ActionResult> GameArtwork(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
List<Artwork> artworks = new List<Artwork>();
if (game.Artworks != null)
@@ -423,15 +427,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/artwork/{ArtworkId}")]
[Route("{MetadataMapId}/artwork/{ArtworkId}")]
[ProducesResponseType(typeof(Artwork), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameArtwork(long GameId, long ArtworkId)
public async Task<ActionResult> GameArtwork(long MetadataMapId, long ArtworkId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
try
{
@@ -459,15 +464,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/cover")]
[Route("{MetadataMapId}/cover")]
[ProducesResponseType(typeof(Cover), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameCover(long GameId)
public async Task<ActionResult> GameCover(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
Cover coverObject = Covers.GetCover(game.MetadataSource, (long?)game.Cover);
@@ -494,15 +500,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/{ImageType}/{ImageId}/image/{size}")]
[Route("{GameId}/{ImageType}/{ImageId}/image/{size}/{imagename}")]
[Route("{MetadataMapId}/{ImageType}/{ImageId}/image/{size}")]
[Route("{MetadataMapId}/{ImageType}/{ImageId}/image/{size}/{imagename}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameImage(long GameId, MetadataImageType imageType, long ImageId, Communications.IGDBAPI_ImageSize size, string imagename = "")
public async Task<ActionResult> GameImage(long MetadataMapId, MetadataImageType imageType, long ImageId, Communications.IGDBAPI_ImageSize size, string imagename = "")
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
string? imageId = null;
string? imageTypePath = null;
@@ -630,14 +637,15 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/favourite")]
[Route("{MetadataMapId}/favourite")]
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameGetFavouriteAsync(long GameId)
public async Task<ActionResult> GameGetFavouriteAsync(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
@@ -646,7 +654,7 @@ namespace gaseous_server.Controllers
if (user != null)
{
Favourites favourites = new Favourites();
return Ok(favourites.GetFavourite(user.Id, GameId));
return Ok(favourites.GetFavourite(user.Id, MetadataMapId));
}
else
{
@@ -667,14 +675,15 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpPost]
[Route("{GameId}/favourite")]
[Route("{MetadataMapId}/favourite")]
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameSetFavouriteAsync(long GameId, bool favourite)
public async Task<ActionResult> GameSetFavouriteAsync(long MetadataMapId, bool favourite)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
@@ -683,7 +692,7 @@ namespace gaseous_server.Controllers
if (user != null)
{
Favourites favourites = new Favourites();
return Ok(favourites.SetFavourite(user.Id, GameId, favourite));
return Ok(favourites.SetFavourite(user.Id, MetadataMapId, favourite));
}
else
{
@@ -704,15 +713,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/gamemode")]
[Route("{MetadataMapId}/gamemode")]
[ProducesResponseType(typeof(List<GameMode>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameMode(long GameId)
public async Task<ActionResult> GameMode(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
List<GameMode> gameModeObjects = new List<GameMode>();
@@ -740,15 +750,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/genre")]
[Route("{MetadataMapId}/genre")]
[ProducesResponseType(typeof(List<Genre>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameGenre(long GameId)
public async Task<ActionResult> GameGenre(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
List<Genre> genreObjects = new List<Genre>();
@@ -778,15 +789,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/companies")]
[Route("{MetadataMapId}/companies")]
[ProducesResponseType(typeof(List<Dictionary<string, object>>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameInvolvedCompanies(long GameId)
public async Task<ActionResult> GameInvolvedCompanies(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
List<Dictionary<string, object>> icObjects = new List<Dictionary<string, object>>();
@@ -823,15 +835,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/companies/{CompanyId}")]
[Route("{MetadataMapId}/companies/{CompanyId}")]
[ProducesResponseType(typeof(Dictionary<string, object>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameInvolvedCompanies(long GameId, long CompanyId)
public async Task<ActionResult> GameInvolvedCompanies(long MetadataMapId, long CompanyId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
List<Dictionary<string, object>> icObjects = new List<Dictionary<string, object>>();
@@ -867,14 +880,15 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/companies/{CompanyId}/image")]
[Route("{MetadataMapId}/companies/{CompanyId}/image")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameCompanyImage(long GameId, long CompanyId)
public async Task<ActionResult> GameCompanyImage(long MetadataMapId, long CompanyId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
InvolvedCompany involvedCompany = Classes.Metadata.InvolvedCompanies.GetInvolvedCompanies(CompanyId);
Company company = Classes.Metadata.Companies.GetCompanies(game.MetadataSource, (long?)involvedCompany.Company);
@@ -912,15 +926,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/emulatorconfiguration/{PlatformId}")]
[Route("{MetadataMapId}/emulatorconfiguration/{PlatformId}")]
[Authorize]
[ProducesResponseType(typeof(UserEmulatorConfiguration), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GetGameEmulator(long GameId, long PlatformId)
public async Task<ActionResult> GetGameEmulator(long MetadataMapId, long PlatformId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
@@ -933,7 +948,7 @@ namespace gaseous_server.Controllers
if (user != null)
{
PlatformMapping platformMapping = new PlatformMapping();
UserEmulatorConfiguration platformMappingObject = platformMapping.GetUserEmulator(user.Id, GameId, PlatformId);
UserEmulatorConfiguration platformMappingObject = platformMapping.GetUserEmulator(user.Id, MetadataMapId, PlatformId);
if (platformMappingObject != null)
{
@@ -954,15 +969,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpPost]
[Route("{GameId}/emulatorconfiguration/{PlatformId}")]
[Route("{MetadataMapId}/emulatorconfiguration/{PlatformId}")]
[Authorize]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> SetGameEmulator(long GameId, long PlatformId, UserEmulatorConfiguration configuration)
public async Task<ActionResult> SetGameEmulator(long MetadataMapId, long PlatformId, UserEmulatorConfiguration configuration)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
@@ -975,7 +991,7 @@ namespace gaseous_server.Controllers
if (user != null)
{
PlatformMapping platformMapping = new PlatformMapping();
platformMapping.SetUserEmulator(user.Id, GameId, PlatformId, configuration);
platformMapping.SetUserEmulator(user.Id, MetadataMapId, PlatformId, configuration);
return Ok();
}
@@ -993,15 +1009,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpDelete]
[Route("{GameId}/emulatorconfiguration/{PlatformId}")]
[Route("{MetadataMapId}/emulatorconfiguration/{PlatformId}")]
[Authorize]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> DeleteGameEmulator(long GameId, long PlatformId)
public async Task<ActionResult> DeleteGameEmulator(long MetadataMapId, long PlatformId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
@@ -1014,7 +1031,7 @@ namespace gaseous_server.Controllers
if (user != null)
{
PlatformMapping platformMapping = new PlatformMapping();
platformMapping.DeleteUserEmulator(user.Id, GameId, PlatformId);
platformMapping.DeleteUserEmulator(user.Id, MetadataMapId, PlatformId);
return Ok();
}
@@ -1032,10 +1049,10 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/platforms")]
[Route("{MetadataMapId}/platforms")]
[ProducesResponseType(typeof(List<Games.AvailablePlatformItem>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GamePlatforms(long GameId)
public async Task<ActionResult> GamePlatforms(long MetadataMapId)
{
try
{
@@ -1043,7 +1060,7 @@ namespace gaseous_server.Controllers
if (user != null)
{
return Ok(Games.GetAvailablePlatforms(user.Id, GameId));
return Ok(Games.GetAvailablePlatforms(user.Id, MetadataMapId));
}
else
{
@@ -1059,15 +1076,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/releasedates")]
[Route("{MetadataMapId}/releasedates")]
[ProducesResponseType(typeof(List<ReleaseDate>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameReleaseDates(long GameId)
public async Task<ActionResult> GameReleaseDates(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
List<ReleaseDate> rdObjects = new List<ReleaseDate>();
@@ -1097,19 +1115,20 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/roms")]
[Route("{MetadataMapId}/roms")]
[ProducesResponseType(typeof(Classes.Roms.GameRomObject), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
//[ResponseCache(CacheProfileName = "5Minute")]
public async Task<ActionResult> GameRomAsync(long GameId, int pageNumber = 0, int pageSize = 0, long PlatformId = -1, string NameSearch = "")
public async Task<ActionResult> GameRomAsync(long MetadataMapId, int pageNumber = 0, int pageSize = 0, long PlatformId = -1, string NameSearch = "")
{
var user = await _userManager.GetUserAsync(User);
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
return Ok(Classes.Roms.GetRoms(GameId, PlatformId, NameSearch, pageNumber, pageSize, user.Id));
return Ok(Classes.Roms.GetRoms(MetadataMapId, PlatformId, NameSearch, pageNumber, pageSize, user.Id));
}
catch
{
@@ -1120,18 +1139,19 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/roms/{RomId}")]
[Route("{MetadataMapId}/roms/{RomId}")]
[ProducesResponseType(typeof(Classes.Roms.GameRomItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
//[ResponseCache(CacheProfileName = "5Minute")]
public async Task<ActionResult> GameRom(long GameId, long RomId)
public async Task<ActionResult> GameRom(long MetadataMapId, long RomId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Classes.Roms.GameRomItem rom = Classes.Roms.GetRom(RomId);
if (rom.GameId == GameId)
if (rom.GameId == MetadataMapId)
{
return Ok(rom);
}
@@ -1150,17 +1170,18 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.1")]
[HttpPatch]
[Authorize(Roles = "Admin,Gamer")]
[Route("{GameId}/roms/{RomId}")]
[Route("{MetadataMapId}/roms/{RomId}")]
[ProducesResponseType(typeof(Classes.Roms.GameRomItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameRomRename(long GameId, long RomId, long NewPlatformId, long NewGameId)
public async Task<ActionResult> GameRomRename(long MetadataMapId, long RomId, long NewPlatformId, long NewGameId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Classes.Roms.GameRomItem rom = Classes.Roms.GetRom(RomId);
if (rom.GameId == GameId)
if (rom.GameId == MetadataMapId)
{
rom = Classes.Roms.UpdateRom(RomId, NewPlatformId, NewGameId);
return Ok(rom);
@@ -1180,17 +1201,18 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.1")]
[HttpDelete]
[Authorize(Roles = "Admin,Gamer")]
[Route("{GameId}/roms/{RomId}")]
[Route("{MetadataMapId}/roms/{RomId}")]
[ProducesResponseType(typeof(Classes.Roms.GameRomItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameRomDelete(long GameId, long RomId)
public async Task<ActionResult> GameRomDelete(long MetadataMapId, long RomId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Classes.Roms.GameRomItem rom = Classes.Roms.GetRom(RomId);
if (rom.GameId == GameId)
if (rom.GameId == MetadataMapId)
{
Classes.Roms.DeleteRom(RomId);
return Ok(rom);
@@ -1209,29 +1231,30 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpPost]
[Route("{GameId}/roms/{RomId}/{PlatformId}/favourite")]
[Route("{MetadataMapId}/roms/{RomId}/{PlatformId}/favourite")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameRomFavourite(long GameId, long RomId, long PlatformId, bool IsMediaGroup, bool favourite)
public async Task<ActionResult> GameRomFavourite(long MetadataMapId, long RomId, long PlatformId, bool IsMediaGroup, bool favourite)
{
try
{
ApplicationUser? user = await _userManager.GetUserAsync(User);
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (IsMediaGroup == false)
{
Classes.Roms.GameRomItem rom = Classes.Roms.GetRom(RomId);
if (rom.GameId == GameId)
if (rom.GameId == MetadataMapId)
{
if (favourite == true)
{
Classes.Metadata.Games.GameSetFavouriteRom(user.Id, GameId, PlatformId, RomId, IsMediaGroup);
Classes.Metadata.Games.GameSetFavouriteRom(user.Id, MetadataMapId, PlatformId, RomId, IsMediaGroup);
}
else
{
Classes.Metadata.Games.GameClearFavouriteRom(user.Id, GameId, PlatformId);
Classes.Metadata.Games.GameClearFavouriteRom(user.Id, MetadataMapId, PlatformId);
}
return Ok();
}
@@ -1243,15 +1266,15 @@ namespace gaseous_server.Controllers
else
{
Classes.RomMediaGroup.GameRomMediaGroupItem rom = Classes.RomMediaGroup.GetMediaGroup(RomId, user.Id);
if (rom.GameId == GameId)
if (rom.GameId == MetadataMapId)
{
if (favourite == true)
{
Classes.Metadata.Games.GameSetFavouriteRom(user.Id, GameId, PlatformId, RomId, IsMediaGroup);
Classes.Metadata.Games.GameSetFavouriteRom(user.Id, MetadataMapId, PlatformId, RomId, IsMediaGroup);
}
else
{
Classes.Metadata.Games.GameClearFavouriteRom(user.Id, GameId, PlatformId);
Classes.Metadata.Games.GameClearFavouriteRom(user.Id, MetadataMapId, PlatformId);
}
return Ok();
}
@@ -1273,17 +1296,18 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpHead]
[Route("{GameId}/roms/{RomId}/file")]
[Route("{MetadataMapId}/roms/{RomId}/file")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameRomFile(long GameId, long RomId)
public async Task<ActionResult> GameRomFile(long MetadataMapId, long RomId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Classes.Roms.GameRomItem rom = Classes.Roms.GetRom(RomId);
if (rom.GameId != GameId)
if (rom.GameId != MetadataMapId)
{
return NotFound();
}
@@ -1312,17 +1336,18 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpHead]
[Route("{GameId}/roms/{RomId}/{FileName}")]
[Route("{MetadataMapId}/roms/{RomId}/{FileName}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameRomFile(long GameId, long RomId, string FileName)
public async Task<ActionResult> GameRomFile(long MetadataMapId, long RomId, string FileName)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Classes.Roms.GameRomItem rom = Classes.Roms.GetRom(RomId);
if (rom.GameId != GameId || rom.Name != FileName)
if (rom.GameId != MetadataMapId || rom.Name != FileName)
{
return NotFound();
}
@@ -1348,20 +1373,21 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/romgroup/{RomGroupId}")]
[Route("{MetadataMapId}/romgroup/{RomGroupId}")]
[ProducesResponseType(typeof(Classes.RomMediaGroup.GameRomMediaGroupItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
//[ResponseCache(CacheProfileName = "5Minute")]
public async Task<ActionResult> GameRomGroupAsync(long GameId, long RomGroupId)
public async Task<ActionResult> GameRomGroupAsync(long MetadataMapId, long RomGroupId)
{
var user = await _userManager.GetUserAsync(User);
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Classes.RomMediaGroup.GameRomMediaGroupItem rom = Classes.RomMediaGroup.GetMediaGroup(RomGroupId, user.Id);
if (rom.GameId == GameId)
if (rom.GameId == MetadataMapId)
{
return Ok(rom);
}
@@ -1379,20 +1405,21 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/romgroup")]
[Route("{MetadataMapId}/romgroup")]
[ProducesResponseType(typeof(List<RomMediaGroup.GameRomMediaGroupItem>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GetGameRomGroupAsync(long GameId, long? PlatformId = null)
public async Task<ActionResult> GetGameRomGroupAsync(long MetadataMapId, long? PlatformId = null)
{
var user = await _userManager.GetUserAsync(User);
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
try
{
return Ok(RomMediaGroup.GetMediaGroupsFromGameId(GameId, user.Id, PlatformId));
return Ok(RomMediaGroup.GetMediaGroupsFromGameId(MetadataMapId, user.Id, PlatformId));
}
catch (Exception ex)
{
@@ -1410,18 +1437,19 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.1")]
[HttpPost]
[Authorize(Roles = "Admin,Gamer")]
[Route("{GameId}/romgroup")]
[Route("{MetadataMapId}/romgroup")]
[ProducesResponseType(typeof(Classes.RomMediaGroup.GameRomMediaGroupItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> NewGameRomGroup(long GameId, long PlatformId, [FromBody] List<long> RomIds)
public async Task<ActionResult> NewGameRomGroup(long MetadataMapId, long PlatformId, [FromBody] List<long> RomIds)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
try
{
Classes.RomMediaGroup.GameRomMediaGroupItem rom = Classes.RomMediaGroup.CreateMediaGroup(GameId, PlatformId, RomIds);
Classes.RomMediaGroup.GameRomMediaGroupItem rom = Classes.RomMediaGroup.CreateMediaGroup(MetadataMapId, PlatformId, RomIds);
return Ok(rom);
}
catch
@@ -1439,19 +1467,20 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.1")]
[HttpPatch]
[Authorize(Roles = "Admin,Gamer")]
[Route("{GameId}/romgroup/{RomId}")]
[Route("{MetadataMapId}/romgroup/{RomId}")]
[ProducesResponseType(typeof(Classes.RomMediaGroup.GameRomMediaGroupItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameRomGroupMembersAsync(long GameId, long RomGroupId, [FromBody] List<long> RomIds)
public async Task<ActionResult> GameRomGroupMembersAsync(long MetadataMapId, long RomGroupId, [FromBody] List<long> RomIds)
{
var user = await _userManager.GetUserAsync(User);
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Classes.RomMediaGroup.GameRomMediaGroupItem rom = Classes.RomMediaGroup.GetMediaGroup(RomGroupId, user.Id);
if (rom.GameId == GameId)
if (rom.GameId == MetadataMapId)
{
rom = Classes.RomMediaGroup.EditMediaGroup(RomGroupId, RomIds);
return Ok(rom);
@@ -1471,17 +1500,18 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.1")]
[HttpDelete]
[Authorize(Roles = "Admin,Gamer")]
[Route("{GameId}/romgroup/{RomGroupId}")]
[Route("{MetadataMapId}/romgroup/{RomGroupId}")]
[ProducesResponseType(typeof(Classes.RomMediaGroup.GameRomMediaGroupItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameRomGroupDelete(long GameId, long RomGroupId)
public async Task<ActionResult> GameRomGroupDelete(long MetadataMapId, long RomGroupId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Classes.RomMediaGroup.GameRomMediaGroupItem rom = Classes.RomMediaGroup.GetMediaGroup(RomGroupId);
if (rom.GameId == GameId)
if (rom.GameId == MetadataMapId)
{
Classes.RomMediaGroup.DeleteMediaGroup(RomGroupId);
return Ok(rom);
@@ -1503,18 +1533,19 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpHead]
[Route("{GameId}/romgroup/{RomGroupId}/file")]
[Route("{GameId}/romgroup/{RomGroupId}/{filename}")]
[Route("{MetadataMapId}/romgroup/{RomGroupId}/file")]
[Route("{MetadataMapId}/romgroup/{RomGroupId}/{filename}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GameRomGroupFile(long GameId, long RomGroupId, string filename = "")
public async Task<ActionResult> GameRomGroupFile(long MetadataMapId, long RomGroupId, string filename = "")
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Classes.RomMediaGroup.GameRomMediaGroupItem rom = Classes.RomMediaGroup.GetMediaGroup(RomGroupId);
if (rom.GameId != GameId)
if (rom.GameId != MetadataMapId)
{
return NotFound();
}
@@ -1589,15 +1620,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/screenshots")]
[Route("{MetadataMapId}/screenshots")]
[ProducesResponseType(typeof(List<Screenshot>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameScreenshot(long GameId)
public async Task<ActionResult> GameScreenshot(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
List<Screenshot> screenshots = new List<Screenshot>();
if (game.Screenshots != null)
@@ -1620,15 +1652,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/screenshots/{ScreenshotId}")]
[Route("{MetadataMapId}/screenshots/{ScreenshotId}")]
[ProducesResponseType(typeof(Screenshot), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameScreenshot(long GameId, long ScreenshotId)
public async Task<ActionResult> GameScreenshot(long MetadataMapId, long ScreenshotId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
if (game != null)
{
Screenshot screenshotObject = Screenshots.GetScreenshot(game.MetadataSource, ScreenshotId);
@@ -1655,15 +1688,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/videos")]
[Route("{MetadataMapId}/videos")]
[ProducesResponseType(typeof(List<GameVideo>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")]
public async Task<ActionResult> GameVideo(long GameId)
public async Task<ActionResult> GameVideo(long MetadataMapId)
{
try
{
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
List<GameVideo> videos = new List<GameVideo>();
if (game.Videos != null)

View File

@@ -19,6 +19,7 @@ using static gaseous_server.Classes.Metadata.AgeRatings;
using Asp.Versioning;
using Humanizer;
using HasheousClient.Models.Metadata.IGDB;
using gaseous_server.Models;
namespace gaseous_server.Controllers.v1_1
{
@@ -97,9 +98,9 @@ namespace gaseous_server.Controllers.v1_1
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/Related")]
[Route("{MetadataMapId}/Related")]
[ProducesResponseType(typeof(GameReturnPackage), StatusCodes.Status200OK)]
public async Task<IActionResult> GameRelated(long GameId)
public async Task<IActionResult> GameRelated(long MetadataMapId)
{
var user = await _userManager.GetUserAsync(User);
@@ -114,7 +115,7 @@ namespace gaseous_server.Controllers.v1_1
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "SELECT view_Games.Id, view_Games.AgeGroupId, Relation_Game_SimilarGames.SimilarGamesId FROM view_Games JOIN Relation_Game_SimilarGames ON view_Games.Id = Relation_Game_SimilarGames.GameId AND Relation_Game_SimilarGames.SimilarGamesId IN (SELECT Id FROM view_Games) WHERE view_Games.Id = @id AND (view_Games.AgeGroupId <= @agegroupid" + IncludeUnrated + ")";
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("id", GameId);
dbDict.Add("id", MetadataMapId);
dbDict.Add("agegroupid", (int)user.SecurityProfile.AgeRestrictionPolicy.MaximumAgeRestriction);
List<Models.Game> RetVal = new List<Models.Game>();
@@ -123,7 +124,8 @@ namespace gaseous_server.Controllers.v1_1
foreach (DataRow dr in dbResponse.Rows)
{
RetVal.Add(Classes.Metadata.Games.GetGame(Communications.MetadataSource, (long)dr["SimilarGamesId"]));
MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(MetadataMapId).PreferredMetadataMapItem;
RetVal.Add(Classes.Metadata.Games.GetGame(metadataMap.SourceType, (long)dr["SimilarGamesId"]));
}
GameReturnPackage gameReturn = new GameReturnPackage(RetVal.Count, RetVal);

View File

@@ -8,6 +8,17 @@ namespace gaseous_server.Models
public long PlatformId { get; set; }
public string SignatureGameName { get; set; }
public List<MetadataMapItem> MetadataMapItems { get; set; }
public MetadataMapItem? PreferredMetadataMapItem
{
get
{
if (MetadataMapItems == null || MetadataMapItems.Count == 0)
{
return null;
}
return MetadataMapItems.FirstOrDefault(mmi => mmi.Preferred);
}
}
public class MetadataMapItem
{

View File

@@ -51,8 +51,9 @@ function SetupPage() {
}
// get summary
var gameSummaryLabel = document.getElementById('gamesummarytext_label');
let gameSummaryBox = document.getElementById('gamesummarytext');
if (result.summary || result.storyline) {
let gameSummaryLabel = document.getElementById('gamesummarytext_label');
if (result.summary) {
gameSummaryLabel.innerHTML = result.summary.replaceAll("\n", "<br />");
} else {
@@ -68,7 +69,7 @@ function SetupPage() {
// your element doesn't overflow (not truncated)
}
} else {
gameSummaryLabel.setAttribute('style', 'display: none;');
gameSummaryBox.setAttribute('style', 'display: none;');
}
// load cover

View File

@@ -60,7 +60,6 @@ var pageReloadInterval;
var firstLoad = true;
function formatGamesPanel(targetElement, result, pageNumber, pageSize, forceScrollTop) {
console.log(result);
// set page mode buttons
let pageViewButton = document.getElementById('games_library_button_pagedview');
let infiniteViewButton = document.getElementById('games_library_button_infiniteview');
@@ -406,10 +405,12 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification,
showFavourite = true;
}
console.log(gameObject);
let classes = getViewModeClasses(listView);
let gameBox = document.createElement('div');
gameBox.id = "game_tile_" + gameObject.id;
gameBox.metadataMapId = "game_tile_" + gameObject.metadataMapId;
if (useSmallCover == true) {
gameBox.classList.add(...classes['game_tile game_tile_small']);
} else {
@@ -420,14 +421,14 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification,
let gameImageBox = document.createElement('div');
gameImageBox.classList.add(...classes['game_tile_box']);
if (listView == true) {
gameBox.setAttribute('onclick', 'window.location.href = "/index.html?page=game&id=' + gameObject.id + '";');
gameBox.setAttribute('onclick', 'window.location.href = "/index.html?page=game&id=' + gameObject.metadataMapId + '";');
} else {
gameImageBox.setAttribute('onclick', 'window.location.href = "/index.html?page=game&id=' + gameObject.id + '";');
gameImageBox.setAttribute('onclick', 'window.location.href = "/index.html?page=game&id=' + gameObject.metadataMapId + '";');
}
let gameImage = document.createElement('img');
gameImage.id = 'game_tile_cover_' + gameObject.id;
gameImage.setAttribute('data-id', gameObject.id);
gameImage.id = 'game_tile_cover_' + gameObject.metadataMapId;
gameImage.setAttribute('data-id', gameObject.metadataMapId);
if (useSmallCover == true) {
gameImage.classList.add(...classes['game_tile_image game_tile_image_small lazy']);
} else {
@@ -435,7 +436,7 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification,
}
// gameImage.src = '/images/unknowngame.png';
if (gameObject.cover) {
gameImage.setAttribute('data-src', '/api/v1.1/Games/' + gameObject.id + '/cover/' + gameObject.cover + '/image/cover_big/' + gameObject.cover + '.jpg');
gameImage.setAttribute('data-src', '/api/v1.1/Games/' + gameObject.metadataMapId + '/cover/' + gameObject.cover + '/image/cover_big/' + gameObject.cover + '.jpg');
} else {
gameImage.classList.add(...classes['game_tile_image unknown']);
gameImage.setAttribute('data-src', '/images/unknowngame.png');
@@ -531,7 +532,7 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification,
gameObject.isFavourite = true;
}
fetch('/api/v1.1/Games/' + gameObject.id + '/favourite?favourite=' + gameObject.isFavourite, {
fetch('/api/v1.1/Games/' + gameObject.metaDataMapId + '/favourite?favourite=' + gameObject.isFavourite, {
method: 'POST'
}).then(response => {
if (response.ok) {