From 0239ffbb271669c85f586e7dad3adda5f3ef1319 Mon Sep 17 00:00:00 2001 From: Jeddunk Date: Sun, 29 Aug 2021 22:42:33 +0200 Subject: [PATCH] Fixed DLC crash --- GoldbergGUI.Core/Models/GoldbergModel.cs | 12 ++++++++++++ GoldbergGUI.Core/Models/SteamAppModel.cs | 2 +- GoldbergGUI.Core/Services/SteamService.cs | 14 +++++++------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/GoldbergGUI.Core/Models/GoldbergModel.cs b/GoldbergGUI.Core/Models/GoldbergModel.cs index e7ef7ab..b0f01d2 100644 --- a/GoldbergGUI.Core/Models/GoldbergModel.cs +++ b/GoldbergGUI.Core/Models/GoldbergModel.cs @@ -69,6 +69,18 @@ namespace GoldbergGUI.Core.Models public class DlcApp : SteamApp { + public DlcApp() { } + + public DlcApp(SteamApp steamApp) + { + this.AppId = steamApp.AppId; + this.Name = steamApp.Name; + this.ComparableName = steamApp.ComparableName; + this.AppType = steamApp.AppType; + this.LastModified = steamApp.LastModified; + this.PriceChangeNumber = steamApp.PriceChangeNumber; + } + /// /// Path to DLC (relative to Steam API DLL) (optional) /// diff --git a/GoldbergGUI.Core/Models/SteamAppModel.cs b/GoldbergGUI.Core/Models/SteamAppModel.cs index eb1583f..b3ea457 100644 --- a/GoldbergGUI.Core/Models/SteamAppModel.cs +++ b/GoldbergGUI.Core/Models/SteamAppModel.cs @@ -32,7 +32,7 @@ namespace GoldbergGUI.Core.Models /// App type (Game, DLC, ...) /// [Column("type")] - public string type { get; set; } + public string AppType { get; set; } public override string ToString() { diff --git a/GoldbergGUI.Core/Services/SteamService.cs b/GoldbergGUI.Core/Services/SteamService.cs index 83fdf90..a80ef7f 100644 --- a/GoldbergGUI.Core/Services/SteamService.cs +++ b/GoldbergGUI.Core/Services/SteamService.cs @@ -128,7 +128,7 @@ namespace GoldbergGUI.Core.Services var cache = new HashSet(); foreach (var steamApp in cacheRaw) { - steamApp.type = steamCache.SteamAppType; + steamApp.AppType = steamCache.SteamAppType; steamApp.ComparableName = PrepareStringToCompare(steamApp.Name); cache.Add(steamApp); } @@ -141,7 +141,7 @@ namespace GoldbergGUI.Core.Services public async Task> GetListOfAppsByName(string name) { var query = await _db.Table() - .Where(x => x.type == AppTypeGame).ToListAsync().ConfigureAwait(false); + .Where(x => x.AppType == AppTypeGame).ToListAsync().ConfigureAwait(false); var listOfAppsByName = query.Search(x => x.Name) .SetCulture(StringComparison.OrdinalIgnoreCase) .ContainingAll(name.Split(' ')); @@ -153,7 +153,7 @@ namespace GoldbergGUI.Core.Services _log.Info($"Trying to get app {name}"); var comparableName = PrepareStringToCompare(name); var app = await _db.Table() - .FirstOrDefaultAsync(x => x.type == AppTypeGame && x.ComparableName.Equals(comparableName)) + .FirstOrDefaultAsync(x => x.AppType == AppTypeGame && x.ComparableName.Equals(comparableName)) .ConfigureAwait(false); if (app != null) _log.Info($"Successfully got app {app}"); return app; @@ -162,7 +162,7 @@ namespace GoldbergGUI.Core.Services public async Task GetAppById(int appid) { _log.Info($"Trying to get app with ID {appid}"); - var app = await _db.Table().Where(x => x.type == AppTypeGame) + var app = await _db.Table().Where(x => x.AppType == AppTypeGame) .FirstOrDefaultAsync(x => x.AppId.Equals(appid)).ConfigureAwait(false); if (app != null) _log.Info($"Successfully got app {app}"); return app; @@ -180,10 +180,10 @@ namespace GoldbergGUI.Core.Services { steamAppDetails.DLC.ForEach(async x => { - var result = await _db.Table().Where(z => z.type == AppTypeDlc) + var result = await _db.Table().Where(z => z.AppType == AppTypeDlc) .FirstOrDefaultAsync(y => y.AppId.Equals(x)).ConfigureAwait(true) - ?? new DlcApp() {AppId = x, Name = $"Unknown DLC {x}"}; - dlcList.Add(result); + ?? new SteamApp() { AppId = x, Name = $"Unknown DLC {x}", ComparableName = $"unknownDlc{x}", AppType = AppTypeDlc }; + dlcList.Add(new DlcApp(result)); _log.Debug($"{result.AppId}={result.Name}"); });