public async Task <DestinyCharacterResponse> GetCharacterInventoryResponse(long id) { var account = await GetAccount(); DestinyComponentType[] types = new DestinyComponentType[] { DestinyComponentType.Profiles, DestinyComponentType.Characters, DestinyComponentType.CharacterInventories, DestinyComponentType.CharacterEquipment, }; return(await Util.RequestAndRetry(() => destinyApi.GetCharacterInfo(oauthManager.currentToken.AccessToken, BungieMembershipType.TigerSteam, account.MembershipId, id, types))); }
public async Task <IActionResult> Details(int type, long id) { _affinitization.SetCookies(Request.Cookies); var membershipType = (BungieMembershipType)type; _logger.LogInformation($"{membershipType}/{id}"); var accessToken = await _contextAccessor.HttpContext.GetTokenAsync("access_token"); var model = new AccountDetailsViewModel(membershipType, id); var profileResponse = await _destiny.GetProfile(accessToken, membershipType, id, DestinyComponentType.Characters, DestinyComponentType.CharacterProgressions); if (profileResponse == null) { var url = Url.RouteUrl("AccountIndex"); return(Redirect(url)); } foreach (var item in profileResponse.Characters.Data) { var classDef = await _manifest.LoadClass(item.Value.ClassHash); model.Characters.Add(new Character(item.Key, item.Value, classDef, _bungie.Value.BaseUrl)); if (model.SeasonPassInfo == null) { var characterProgression = await _destiny.GetCharacterInfo(accessToken, membershipType, id, item.Key, DestinyComponentType.CharacterProgressions); model.SeasonPassInfo = await _recommendations.GetSeasonPassInfo(characterProgression.Progressions.Data.Progressions); } } foreach (var cookie in _affinitization.GetCookies()) { Response.Cookies.Append(cookie.name, cookie.value); } return(View(model)); }
public async Task <IActionResult> Details(int type, long id, long characterId) { _affinitization.SetCookies(Request.Cookies); var membershipType = (BungieMembershipType)type; _logger.LogInformation($"{membershipType}/{id}/{characterId}"); var accessToken = await _contextAccessor.HttpContext.GetTokenAsync("access_token"); var profileTask = _destiny.GetProfile(accessToken, membershipType, id, DestinyComponentType.ProfileInventories, DestinyComponentType.Characters, DestinyComponentType.CharacterInventories, DestinyComponentType.CharacterEquipment, DestinyComponentType.ItemInstances, DestinyComponentType.ProfileProgression); var characterProgressionsTask = _destiny.GetCharacterInfo(accessToken, membershipType, id, characterId, DestinyComponentType.Characters, DestinyComponentType.CharacterProgressions); await Task.WhenAll(profileTask, characterProgressionsTask); var profile = profileTask.Result; var characterProgressions = characterProgressionsTask.Result; if (!profile.Characters.Data.TryGetValue(characterId, out var character)) { _logger.LogWarning($"Could not find character {characterId}"); return(null); } var maxGear = await _maxPower.ComputeMaxPower(character, profile.CharacterEquipment.Data.Values, profile.CharacterInventories.Data.Values, profile.ProfileInventory.Data, profile.ItemComponents.Instances.Data); if (maxGear == null) { _logger.LogWarning("Couldn't find max gear. Redirecting to Account Index"); var url = Url.RouteUrl("AccountIndex"); return(Redirect(url)); } var inventory = Enumerable.Empty <DestinyItemComponent>(); if (profile.CharacterInventories.Data.TryGetValue(characterId, out var inventoryComponent)) { inventory = inventoryComponent.Items; } var engrams = await _itemService.GetEngrams(inventory, profile.ItemComponents.Instances.Data); var lowestItems = _maxPower.FindLowestItems(maxGear.Values).ToList(); var classTask = _manifest.LoadClass(character.ClassHash); var maxPower = _maxPower.ComputePower(maxGear.Values); var recommendationsTask = _recommendations.GetRecommendations(new CharacterRecomendationInfo { Items = maxGear.Values, PowerLevel = maxPower, Progressions = characterProgressions.Progressions.Data.Progressions, Engrams = engrams }); await Task.WhenAll(classTask, recommendationsTask); var emblemPath = string.Empty; var emblemBackgroundPath = string.Empty; if (character.EmblemBackgroundPath != null) { emblemPath = _bungie.Value.BaseUrl + character.EmblemPath; emblemBackgroundPath = _bungie.Value.BaseUrl + character.EmblemBackgroundPath; } var model = new CharacterViewModel() { Type = membershipType, AccountId = id, Id = characterId, Items = maxGear.Values, LowestItems = lowestItems, BasePower = maxPower, BonusPower = profile.ProfileProgression.Data.SeasonalArtifact.PowerBonus, EmblemPath = emblemPath, EmblemBackgroundPath = emblemBackgroundPath, Recommendations = recommendationsTask.Result, Engrams = _recommendations.GetEngramPowerLevels(maxPower), ClassName = classTask.Result.DisplayProperties.Name }; foreach (var cookie in _affinitization.GetCookies()) { Response.Cookies.Append(cookie.name, cookie.value); } return(View(model)); }