/// <summary> /// Get all information about user /// </summary> /// <param name="enteredUserName"> Entered username by user </param> public void GetUserInfo(string enteredUserName) { if (enteredUserName == null) { return; } enteredUserName = enteredUserName.Remove(0, enteredUserName.LastIndexOf("/") + 1); var isContinue = _parseService.GetUserAccountInfo(enteredUserName); _page.Dispatcher.Invoke(() => { if (isContinue) { // write UserInfo data _userData.UserName = _parseService.UserNameParse; _userData.UserGameCount = _parseService.GameCountParse; _userData.UserCountryCode = _parseService.UserCountryCodeParse; _userData.UserAvatar = _parseService.UserAvatarParse; _userData.UserProfileStatus = _parseService.UserProfileStatusParse; _userData.UserProfileState = _parseService.UserProfileStateParse; // initialize ViewModel properties UserName = _userData.UserName; UserGameCount = _userData.UserGameCount; UserCountryCode = _userData.UserCountryCode; UserAvatar = _userData.UserAvatar; UserProfileStatus = _userData.UserProfileStatus; UserProfileState = _userData.UserProfileState; AmountGamesAll = 0; AmountGamesWithCards = 0; GamesAllSumm = 0; GamesWithCardsSumm = 0; PricesAll.Clear(); PricesOnlyCards.Clear(); UserGames.Clear(); CanCloseAvailableAll = true; } }); }
/// <summary> /// Get information abount all available games /// </summary> public void GetAvailableGamesInfo() { var isContinueGames = _parseService.GetUserGamesInfo(); _page.Dispatcher.Invoke(() => { if (isContinueGames && UserName != null) { foreach (var parsedItem in _parseService.UserGames) { UserGames.Add(parsedItem); } } else { MessageBox.Show("No entered user", "No user error"); return; } if (ViewModelHelper.DigGames.Count != 0) { var tempList = ViewModelHelper.DigGames .Where(item => !UserGames.Contains(item)) .ToList(); TempList = tempList; var twmpList = new int[ViewModelHelper.DigGames.Count]; for (int i = 0; i < ViewModelHelper.DigGames.Count; i++) { if (!UserGames.Any(x => x == ViewModelHelper.DigGames[i])) { twmpList[i] = i; } else { twmpList[i] = 0; } } PricesAll.Clear(); PricesAll.Add(0.05); for (int i = 0; i < twmpList.Length; i++) { if (twmpList[i] != 0) { PricesAll.Add(ViewModelHelper.PricesAll[i]); } } GamesAllSumm = Math.Round(PricesAll.Sum(), 3); AmountGamesAll = TempList.Distinct().Count(); for (var i = 0; i < TempList.Count; i++) { if (!UserAllGamesDict.ContainsKey(TempList[i])) { UserAllGamesDict.Add(TempList[i], PricesAll[i]); } } /// write user all info into helper class ViewModelHelper.AllGamesUserHelper = AmountGamesAll; ViewModelHelper.AllGamesUserPriceHelper = GamesAllSumm; ViewModelHelper.UserName = UserName; TempList.Clear(); ListViewSourse.Clear(); foreach (var item in UserAllGamesDict) { ListViewSourse.Add($"Game: {item.Key} | Price: ${item.Value}"); } CanCloseSaveAll = true; } else { MessageBox.Show("No games from DIG", "No dig games error"); return; } CanCloseAvailableAllCards = true; }); }