private Demo CreateNewDemoForShareCode(ShareCode shareCode) { var gameRequest = ShareCodeDecoder.Decode(shareCode.Code); myLogger.LogTrace($"Decoded sharing code {shareCode.Code} into Request with Match ID: {gameRequest.MatchId}, Outcome ID: {gameRequest.OutcomeId} and Token: {gameRequest.Token}"); return(new Demo { ShareCode = shareCode.Code, GameRequest = gameRequest }); }
private ShareCode IncrementDownloadAttemptCount(ShareCode code) { var dbShareCode = ShareCodes.AsEnumerable().Single(x => x.Equals(code)); if (code.DownloadAttempt != dbShareCode.DownloadAttempt) { throw new ArgumentException($"The download attempt count for sharecode {code.Code} differs between the provided instance ({code.DownloadAttempt}) and the db {dbShareCode.DownloadAttempt}"); } dbShareCode.IncrementDownloadAttempts(); if (dbShareCode.DownloadAttempt >= myMaximumDownloadAttempts) { myLogger.LogInformation($"Share code {dbShareCode.Code} reached maximum number of attempts. Removing..."); ShareCodes.Remove(dbShareCode); } SaveChanges(); return(dbShareCode); }