예제 #1
0
        private async void GetUserAchievementsListAsync()
        {
            var trophyRequest = new TrophyRequest()
            {
                UserId = _basicData.UserId
            };

            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                PROBA.UserAchievementsListCanceled(RequestResponse.NoInternet);
                return;
            }
            try
            {
                var(success, statusCode, userAchievements) = await _probaHttpClient.GetUserAchievementsAsync(trophyRequest);

                var(allSuccess, allStatusCode, allAchievements) = await _probaHttpClient.GetAchievementsListAsync(new TrophyRequest());

                if (!success || !allSuccess)
                {
                    PROBA.UserAchievementsListCanceled(RequestResponse.Error);
                    return;
                }

                var prunedUserAchievements = new List <UserAchievementViewModel>();
                foreach (var Achievement in allAchievements)
                {
                    foreach (var userAchievement in userAchievements)
                    {
                        if (userAchievement.AchievementId == Achievement.ID)
                        {
                            userAchievement.AchievementEnName = Achievement.AchievementEnName;
                            userAchievement.AchievementName   = Achievement.AchievementName;
                            prunedUserAchievements.Add(userAchievement);
                            break;
                        }
                    }
                }
                PROBA.UserAchievementsListReceived(prunedUserAchievements);
            }
            catch (Exception e)
            {
                PROBA.UserAchievementsListCanceled(RequestResponse.Error);
                _probaLogger.LogError(e.Message, e.StackTrace);
            }
        }