/// <summary>
        /// Updates the achievements.
        /// </summary>
        /// <param name="steamUserId">The steam user id.</param>
        /// <param name="language">The language.</param>
        /// <returns>
        /// true if successful, else false.
        /// </returns>
        public int UpdateAchievements(string steamUserId, string language = null)
        {
            if (steamUserId == null)
            {
                throw new ArgumentNullException("steamUserId");
            }

            if (language == null)
            {
                language = CultureHelper.GetLanguage();
            }

            ICollection <UserAchievement> achievements =
                _communityService.GetClosedAchievements(steamUserId, language);

            Data.User user = _achievementManager.GetUser(steamUserId);
            if (user == null)
            {
                throw new ArgumentException("User does not exist.", "steamUserId");
            }

            int updated = _achievementManager.UpdateAchievements(achievements.ToDataAchievements(user.FacebookUserId));

            return(updated);
        }
        /// <summary>
        /// Updates the new user's achievements and hides any that are more than 2 days old.
        /// </summary>
        /// <param name="user">The user.</param>
        public void UpdateNewUserAchievements(Models.User user)
        {
            bool exists = _achievementManager.GetUser(user.FacebookUserId) != null;

            if (!exists)
            {
                throw new ArgumentException("The given user does not exist", "user");
            }

            int updatedCount = UpdateAchievements(user.FacebookUserId);

            if (updatedCount > 0)
            {
                // hide achievements more than two days old
                ICollection <Models.Achievement> achievements =
                    GetUnpublishedAchievements(user.FacebookUserId, DateTime.UtcNow.Date.AddDays(-2));
                IEnumerable <int> achievementIds = achievements.Select(achievement => achievement.Id);
                HideAchievements(user.FacebookUserId, achievementIds);
            }
        }
예제 #3
0
        /// <summary>
        /// Gets the user.
        /// </summary>
        /// <param name="facebookUserId">The facebook user id.</param>
        /// <returns></returns>
        public User GetUser(long facebookUserId)
        {
            Data.User user = _manager.GetUser(facebookUserId);

            return(Map(user));
        }
        /// <summary>
        /// Gets the user.
        /// </summary>
        /// <param name="facebookUserId">The facebook user id.</param>
        /// <returns></returns>
        public Models.User GetUser(long facebookUserId)
        {
            Data.User user = _manager.GetUser(facebookUserId);

            return Map(user);
        }