public static Patch GetPatch(string version) { var context = new PatchContext(); var retVal = context.PatchList.Where(p => p.version == version).FirstOrDefault(); if (retVal == null) { return null; } else return retVal; }
static void AddData(RiotClient riotClient, string version = null) { int tryCount = 0; bool gotData = false; ChampionListDto champData = null; ItemListDto itemData = null; do { try { champData = riotClient.LolStaticData.GetChampionList(RiotApiConfig.Regions.EUW, null, null, version, "all"); gotData = true; } catch (Exception ex) { tryCount += 1; if (tryCount % 3 == 0) { System.Threading.Thread.Sleep(60000); } } } while (gotData == false); version = champData.Version; // reset loop variables gotData = false; tryCount = 0; // --------------------- do { try { itemData = riotClient.LolStaticData.GetItemList(RiotApiConfig.Regions.EUW, null, version, "all"); gotData = true; } catch { tryCount += 1; if (tryCount % 3 == 0) { System.Threading.Thread.Sleep(60000); } } } while (gotData == false); if (itemData != null && champData != null) { PatchContext context = new PatchContext(); context.PatchList.Add(new Patch(champData, itemData)); context.SaveChanges(); MailControl.SendMail("Added Patch", $"Patch {version} was successfully added to the database at {DateTime.Now}."); } }