diff --git a/gaseous-server/Classes/MetadataManagement.cs b/gaseous-server/Classes/MetadataManagement.cs index f9278ff..20ae245 100644 --- a/gaseous-server/Classes/MetadataManagement.cs +++ b/gaseous-server/Classes/MetadataManagement.cs @@ -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() { { "@sourceid", HasheousClient.Models.MetadataSources.None }, - { "@name", name } + { "@name", name }, + { "@dateadded", DateTime.UtcNow }, + { "@lastupdated", DateTime.UtcNow } }; dt = db.ExecuteCMD(sql, dbDict); diff --git a/gaseous-server/Controllers/V1.0/GamesController.cs b/gaseous-server/Controllers/V1.0/GamesController.cs index 52a9b30..4cdb275 100644 --- a/gaseous-server/Controllers/V1.0/GamesController.cs +++ b/gaseous-server/Controllers/V1.0/GamesController.cs @@ -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 Game(long GameId) + public async Task 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), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ResponseCache(CacheProfileName = "7Days")] - public async Task GameAlternativeNames(long GameId) + public async Task 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), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ResponseCache(CacheProfileName = "7Days")] - public async Task GameAgeClassification(long GameId) + public async Task 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), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ResponseCache(CacheProfileName = "7Days")] - public async Task GameArtwork(long GameId) + public async Task 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 artworks = new List(); 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 GameArtwork(long GameId, long ArtworkId) + public async Task 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 GameCover(long GameId) + public async Task 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 GameImage(long GameId, MetadataImageType imageType, long ImageId, Communications.IGDBAPI_ImageSize size, string imagename = "") + public async Task 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 GameGetFavouriteAsync(long GameId) + public async Task 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 GameSetFavouriteAsync(long GameId, bool favourite) + public async Task 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), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ResponseCache(CacheProfileName = "7Days")] - public async Task GameMode(long GameId) + public async Task 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 gameModeObjects = new List(); @@ -740,15 +750,16 @@ namespace gaseous_server.Controllers [MapToApiVersion("1.0")] [MapToApiVersion("1.1")] [HttpGet] - [Route("{GameId}/genre")] + [Route("{MetadataMapId}/genre")] [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ResponseCache(CacheProfileName = "7Days")] - public async Task GameGenre(long GameId) + public async Task 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 genreObjects = new List(); @@ -778,15 +789,16 @@ namespace gaseous_server.Controllers [MapToApiVersion("1.0")] [MapToApiVersion("1.1")] [HttpGet] - [Route("{GameId}/companies")] + [Route("{MetadataMapId}/companies")] [ProducesResponseType(typeof(List>), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ResponseCache(CacheProfileName = "7Days")] - public async Task GameInvolvedCompanies(long GameId) + public async Task 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> icObjects = new List>(); @@ -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), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ResponseCache(CacheProfileName = "7Days")] - public async Task GameInvolvedCompanies(long GameId, long CompanyId) + public async Task 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> icObjects = new List>(); @@ -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 GameCompanyImage(long GameId, long CompanyId) + public async Task 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 GetGameEmulator(long GameId, long PlatformId) + public async Task 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 SetGameEmulator(long GameId, long PlatformId, UserEmulatorConfiguration configuration) + public async Task 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 DeleteGameEmulator(long GameId, long PlatformId) + public async Task 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), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task GamePlatforms(long GameId) + public async Task 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), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ResponseCache(CacheProfileName = "7Days")] - public async Task GameReleaseDates(long GameId) + public async Task 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 rdObjects = new List(); @@ -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 GameRomAsync(long GameId, int pageNumber = 0, int pageSize = 0, long PlatformId = -1, string NameSearch = "") + public async Task 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 GameRom(long GameId, long RomId) + public async Task 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 GameRomRename(long GameId, long RomId, long NewPlatformId, long NewGameId) + public async Task 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 GameRomDelete(long GameId, long RomId) + public async Task 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 GameRomFavourite(long GameId, long RomId, long PlatformId, bool IsMediaGroup, bool favourite) + public async Task 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 GameRomFile(long GameId, long RomId) + public async Task 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 GameRomFile(long GameId, long RomId, string FileName) + public async Task 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 GameRomGroupAsync(long GameId, long RomGroupId) + public async Task 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), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task GetGameRomGroupAsync(long GameId, long? PlatformId = null) + public async Task 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 NewGameRomGroup(long GameId, long PlatformId, [FromBody] List RomIds) + public async Task NewGameRomGroup(long MetadataMapId, long PlatformId, [FromBody] List 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 GameRomGroupMembersAsync(long GameId, long RomGroupId, [FromBody] List RomIds) + public async Task GameRomGroupMembersAsync(long MetadataMapId, long RomGroupId, [FromBody] List 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 GameRomGroupDelete(long GameId, long RomGroupId) + public async Task 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 GameRomGroupFile(long GameId, long RomGroupId, string filename = "") + public async Task 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), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ResponseCache(CacheProfileName = "7Days")] - public async Task GameScreenshot(long GameId) + public async Task 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 screenshots = new List(); 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 GameScreenshot(long GameId, long ScreenshotId) + public async Task 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), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ResponseCache(CacheProfileName = "7Days")] - public async Task GameVideo(long GameId) + public async Task 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 videos = new List(); if (game.Videos != null) diff --git a/gaseous-server/Controllers/V1.1/GamesController.cs b/gaseous-server/Controllers/V1.1/GamesController.cs index 1ca8244..dc8ead3 100644 --- a/gaseous-server/Controllers/V1.1/GamesController.cs +++ b/gaseous-server/Controllers/V1.1/GamesController.cs @@ -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 GameRelated(long GameId) + public async Task 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 dbDict = new Dictionary(); - dbDict.Add("id", GameId); + dbDict.Add("id", MetadataMapId); dbDict.Add("agegroupid", (int)user.SecurityProfile.AgeRestrictionPolicy.MaximumAgeRestriction); List RetVal = new List(); @@ -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); diff --git a/gaseous-server/Models/MetadataMap.cs b/gaseous-server/Models/MetadataMap.cs index b4ea862..143091d 100644 --- a/gaseous-server/Models/MetadataMap.cs +++ b/gaseous-server/Models/MetadataMap.cs @@ -8,6 +8,17 @@ namespace gaseous_server.Models public long PlatformId { get; set; } public string SignatureGameName { get; set; } public List MetadataMapItems { get; set; } + public MetadataMapItem? PreferredMetadataMapItem + { + get + { + if (MetadataMapItems == null || MetadataMapItems.Count == 0) + { + return null; + } + return MetadataMapItems.FirstOrDefault(mmi => mmi.Preferred); + } + } public class MetadataMapItem { diff --git a/gaseous-server/wwwroot/pages/game.js b/gaseous-server/wwwroot/pages/game.js index 9d92ab3..824dc8a 100644 --- a/gaseous-server/wwwroot/pages/game.js +++ b/gaseous-server/wwwroot/pages/game.js @@ -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", "
"); } 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 diff --git a/gaseous-server/wwwroot/scripts/gamesformating.js b/gaseous-server/wwwroot/scripts/gamesformating.js index 60f5429..02a707e 100644 --- a/gaseous-server/wwwroot/scripts/gamesformating.js +++ b/gaseous-server/wwwroot/scripts/gamesformating.js @@ -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) {