Exemplo n.º 1
0
        /// <summary>
        /// Update user statistics from different indexes and services if it is not up to date.
        /// </summary>
        /// <param name="user"></param>
        public void LoadUserStatictics(ApplicationUserDto user)
        {
            // No need to go into cache and read stuff if user is up to date.
            // We hope that we covered all the places that will trigger statistics change.
            if (user.IsStatisticsCached)
            {
                return;
            }

            user.NumberOfAnswers      = _answerService.CountByUserId(user.UserId);
            user.NumberOfDescriptions = _answerDescriptionService.CountByUserId(user.UserId);
            user.NumberOfVotes        = _voteService.CountByUserId(user.UserId);
            user.NumberOfFlags        = _flagService.CountByUserId(user.UserId);

            user.IsStatisticsCached = true;
        }