public HomeController(UserManager <AramIdentityUser> userManager, ApplicationDbContext dbContext, IOptions <ApplicationConfiguration> options, ILolStaticDataService lolStatic) { this.userManager = userManager; this.dbContext = dbContext; this.options = options; this.lolStatic = lolStatic; }
private async Task <Rune> GetRuneFromIdAsync(ApplicationDbContext dbContext, ILolStaticDataService lolStatic, int famillyId, int?id = null) { var rune = dbContext.Runes.FirstOrDefault(x => x.Id == (id ?? famillyId)); if (rune == null) { try { var runeData = await lolStatic.GetRuneAsync(famillyId, id); rune = new Rune { Icon = runeData.icon, Id = runeData.id, Name = runeData.name }; dbContext.Add(rune); dbContext.SaveChanges(); } catch (KeyNotFoundException) { return(null); } } return(rune); }
private async Task <Item> GetItemFromIdAsync(ApplicationDbContext dbContext, ILolStaticDataService lolStatic, int id) { var item = dbContext.Items.FirstOrDefault(x => x.Id == id); if (item == null) { try { var itemData = await lolStatic.GetItemAsync(id); item = new Item { Icon = itemData.image.full, Id = id, Name = itemData.name }; dbContext.Add(item); await dbContext.SaveChangesAsync(); } catch (KeyNotFoundException) { return(null); } } return(item); }
public MatchController(UserManager <AramIdentityUser> userManager, ApplicationDbContext dbContext, IOptions <ApplicationConfiguration> options, ILolStaticDataService lolStatic, IRiotAPIService riotAPI, IBackgroundTaskQueue queue, IServiceProvider services) { this.userManager = userManager; this.dbContext = dbContext; this.options = options; this.lolStatic = lolStatic; this.riotAPI = riotAPI; this.queue = queue; this.services = services; }
private async Task <Spell> GetSpellFromIdAsync(ApplicationDbContext dbContext, ILolStaticDataService lolStatic, int id) { var spell = dbContext.Spells.FirstOrDefault(x => x.Id == id); if (spell == null) { try { var itemData = await lolStatic.GetSpellAsync(id); spell = new Spell { Icon = itemData.image.full, Id = id, Name = itemData.name }; dbContext.Add(spell); await dbContext.SaveChangesAsync(); } catch (KeyNotFoundException) { return(null); } } return(spell); }
private async Task <List <LoginGameSpell> > GetSpellsFromParticipantAsync(ApplicationDbContext dbContext, ILolStaticDataService lolStatic, LoginGame lg, Participant participant) { var spells = new List <LoginGameSpell>(); var spell = await GetSpellFromIdAsync(dbContext, lolStatic, participant.spell1Id); if (spell != null) { spells.Add(new LoginGameSpell { Spell = spell, LoginGame = lg, Position = 1 }); } spell = await GetSpellFromIdAsync(dbContext, lolStatic, participant.spell2Id); if (spell != null) { spells.Add(new LoginGameSpell { Spell = spell, LoginGame = lg, Position = 2 }); } return(spells); }
private async Task <List <LoginGameRune> > GetRunesFromStatsAsync(ApplicationDbContext dbContext, ILolStaticDataService lolStatic, LoginGame lg, Stats stats) { var runes = new List <LoginGameRune>(); var rune = await GetRuneFromIdAsync(dbContext, lolStatic, stats.perkPrimaryStyle); if (rune != null) { runes.Add(new LoginGameRune { Rune = rune, LoginGame = lg, Position = 0 }); } rune = await GetRuneFromIdAsync(dbContext, lolStatic, stats.perkPrimaryStyle, stats.perk0); if (rune != null) { runes.Add(new LoginGameRune { Rune = rune, LoginGame = lg, Position = 1 }); } rune = await GetRuneFromIdAsync(dbContext, lolStatic, stats.perkPrimaryStyle, stats.perk1); if (rune != null) { runes.Add(new LoginGameRune { Rune = rune, LoginGame = lg, Position = 2 }); } if (rune != null) { rune = await GetRuneFromIdAsync(dbContext, lolStatic, stats.perkPrimaryStyle, stats.perk2); } runes.Add(new LoginGameRune { Rune = rune, LoginGame = lg, Position = 3 }); rune = await GetRuneFromIdAsync(dbContext, lolStatic, stats.perkPrimaryStyle, stats.perk3); if (rune != null) { runes.Add(new LoginGameRune { Rune = rune, LoginGame = lg, Position = 4 }); } rune = await GetRuneFromIdAsync(dbContext, lolStatic, stats.perkSubStyle); if (rune != null) { runes.Add(new LoginGameRune { Rune = rune, LoginGame = lg, Position = 5 }); } rune = await GetRuneFromIdAsync(dbContext, lolStatic, stats.perkSubStyle, stats.perk4); if (rune != null) { runes.Add(new LoginGameRune { Rune = rune, LoginGame = lg, Position = 6 }); } rune = await GetRuneFromIdAsync(dbContext, lolStatic, stats.perkSubStyle, stats.perk5); if (rune != null) { runes.Add(new LoginGameRune { Rune = rune, LoginGame = lg, Position = 7 }); } return(runes); }
private async Task <List <Item> > GetItemsFromStatsAsync(ApplicationDbContext dbContext, ILolStaticDataService lolStatic, Stats stats) { var items = new List <Item>(); var item0 = await GetItemFromIdAsync(dbContext, lolStatic, stats.item0); if (item0 != null) { items.Add(item0); } var item1 = await GetItemFromIdAsync(dbContext, lolStatic, stats.item1); if (item1 != null) { items.Add(item1); } var item2 = await GetItemFromIdAsync(dbContext, lolStatic, stats.item2); if (item2 != null) { items.Add(item2); } var item3 = await GetItemFromIdAsync(dbContext, lolStatic, stats.item3); if (item3 != null) { items.Add(item3); } var item4 = await GetItemFromIdAsync(dbContext, lolStatic, stats.item4); if (item4 != null) { items.Add(item4); } var item5 = await GetItemFromIdAsync(dbContext, lolStatic, stats.item5); if (item5 != null) { items.Add(item5); } var item6 = await GetItemFromIdAsync(dbContext, lolStatic, stats.item6); if (item6 != null) { items.Add(item6); } return(items); }