public async Task <RuneDto> GetRuneAsync(int familleId, int?id = null) { RuneDto returnItem = null; using (var httpClient = new HttpClient()) { var resp = await httpClient.GetAsync($"{realms.cdn}/{realms.n.item}/data/{realms.l}/runesReforged.json"); if (resp.IsSuccessStatusCode) { var runeData = JsonConvert.DeserializeObject <List <RunesDto> >(await resp.Content.ReadAsStringAsync()); var familleRune = runeData.FirstOrDefault(x => x.id == familleId); if (familleRune != null) { foreach (var rune in familleRune.slots) { returnItem = rune.runes.FirstOrDefault(x => x.id == id); if (returnItem != null) { return(returnItem); } } returnItem = new RuneDto { icon = familleRune.icon, id = familleRune.id, key = familleRune.key, name = familleRune.name }; } } } return(returnItem); }
public static Rune ConvertRuneDtoToRune(RuneDto runeDto) { if (runeDto == null) { return(new Rune()); } try { return(new Rune { //Sub rune RuneId = runeDto.RuneId, RuneName = runeDto.RuneName, RuneIconPath = ImageLocationStrings.RuneSubStyleImagesPath + runeDto.RuneId + ImageLocationStrings.PngFileExtension, //Parent rune RunePathId = runeDto.RunePathId, RunePathName = runeDto.RunePathName, RunePathIconPath = ImageLocationStrings.RuneStyleImagesPath + runeDto.RunePathId + ImageLocationStrings.PngFileExtension, }); } catch (Exception e) { Console.WriteLine("Exception caught when converting RuneDto Style to Rune Style : " + e.Message); } return(new Rune()); }