public async Task UpdateCriticStats(MasterSubGame masterSubGame, OpenCriticGame openCriticGame) { DateTime?releaseDate = null; if (openCriticGame.ReleaseDate.HasValue) { releaseDate = openCriticGame.ReleaseDate.Value.ToDateTimeUnspecified(); } await using var connection = new MySqlConnection(_connectionString); await connection.ExecuteAsync("update tbl_mastergame_subgame set ReleaseDate = @releaseDate, CriticScore = @criticScore where MasterSubGameID = @masterSubGameID", new { masterSubGameID = masterSubGame.MasterSubGameID, releaseDate, criticScore = openCriticGame.Score }); }
public async Task UpdateCriticStats(MasterGame masterGame, OpenCriticGame openCriticGame) { string setFirstTimestamp = ""; if (!masterGame.FirstCriticScoreTimestamp.HasValue && openCriticGame.Score.HasValue) { setFirstTimestamp = ", FirstCriticScoreTimestamp = CURRENT_TIMESTAMP "; } string sql = $"update tbl_mastergame set CriticScore = @criticScore {setFirstTimestamp} where MasterGameID = @masterGameID"; await using var connection = new MySqlConnection(_connectionString); await connection.ExecuteAsync(sql, new { masterGameID = masterGame.MasterGameID, criticScore = openCriticGame.Score }); }
public async Task UpdateCriticStats(MasterGame masterGame, OpenCriticGame openCriticGame) { DateTime?releaseDate = null; if (openCriticGame.ReleaseDate.HasValue) { releaseDate = openCriticGame.ReleaseDate.Value.ToDateTimeUnspecified(); } string setFirstTimestamp = ""; if (!masterGame.CriticScore.HasValue && openCriticGame.Score.HasValue) { setFirstTimestamp = ", FirstCriticScoreTimestamp = CURRENT_TIMESTAMP "; } string setReleaseDate = ""; if (!masterGame.DoNotRefreshDate) { setFirstTimestamp = ", ReleaseDate = @releaseDate "; } string sql = $"update tbl_mastergame set CriticScore = @criticScore {setReleaseDate} {setFirstTimestamp} where MasterGameID = @masterGameID"; using (var connection = new MySqlConnection(_connectionString)) { await connection.ExecuteAsync(sql, new { masterGameID = masterGame.MasterGameID, criticScore = openCriticGame.Score, releaseDate, }); } }
public Task UpdateCriticStats(MasterSubGame masterSubGame, OpenCriticGame openCriticGame) { return(_masterGameRepo.UpdateCriticStats(masterSubGame, openCriticGame)); }
public Task UpdateCriticStats(MasterSubGame masterSubGame, OpenCriticGame openCriticGame) { throw new NotImplementedException(); }
public async Task <OpenCriticGame?> GetOpenCriticGame(int openCriticGameID) { try { var gameResponse = await _client.GetStringAsync($"game/{openCriticGameID}"); if (string.IsNullOrWhiteSpace(gameResponse)) { return(null); } JObject parsedGameResponse = JObject.Parse(gameResponse); var gameName = parsedGameResponse.GetValue("name")?.Value <string>() ?? "Unknown Open Critic Game"; LocalDate?earliestReleaseDate = null; var releaseDateToken = parsedGameResponse.GetValue("firstReleaseDate"); var firstReleaseDateString = releaseDateToken?.Value <string>(); if (!string.IsNullOrWhiteSpace(firstReleaseDateString)) { var earliestDateTime = releaseDateToken?.Value <DateTime>(); if (earliestDateTime.HasValue) { earliestReleaseDate = LocalDate.FromDateTime(earliestDateTime.Value); if (earliestReleaseDate == DefaultOpenCriticReleaseDate) { earliestReleaseDate = null; } } } var score = parsedGameResponse.GetValue("topCriticScore")?.Value <decimal?>(); if (score == -1m) { score = parsedGameResponse.GetValue("averageScore")?.Value <decimal?>(); if (score != -1m) { _logger.LogWarning($"Using averageScore for game: {openCriticGameID}"); } else { score = null; } } var openCriticGame = new OpenCriticGame(openCriticGameID, gameName, score, earliestReleaseDate); return(openCriticGame); } catch (HttpRequestException httpEx) { if (httpEx.Message == "Response status code does not indicate success: 404 (Not Found).") { return(null); } _logger.LogError(httpEx, $"Getting an open critic game failed: {openCriticGameID}"); throw; } catch (Exception e) { _logger.LogError(e, $"Getting an open critic game failed: {openCriticGameID}"); throw; } }
public Task UpdateCriticStats(MasterGame masterGame, OpenCriticGame openCriticGame) { return(_fantasyCriticRepo.UpdateCriticStats(masterGame, openCriticGame)); }