Пример #1
0
        //public async Task<AccountScoreboardVM> GetUsers()
        //{
        //    string userId = userManager.GetUserId(_httpContextAccessor.HttpContext.User);
        //    MyIdentityUser user = await userManager.FindByIdAsync(userId);
        //    var viewModel = new AccountScoreboardVM();
        //    var hej = user.UserName;
        //    viewModel.Users = user.UserName;
        //    viewModel.Score = user.Score;;
        //    return viewModel;
        //}

        public async Task HandleCorrectGuess(int score)
        {
            if (!_httpContextAccessor.HttpContext.User.Identity.IsAuthenticated)
            {
                return;
            }

            string         userId = userManager.GetUserId(_httpContextAccessor.HttpContext.User);
            MyIdentityUser user   = await userManager.FindByIdAsync(userId);

            user.Score += score;

            await userManager.UpdateAsync(user);
        }
Пример #2
0
        public async Task <AccountWelcomeVM> GetUserScore()
        {
            string userId = userManager.GetUserId(_httpContextAccessor.HttpContext.User);

            if (userId == null)
            {
                return(new AccountWelcomeVM());
            }
            MyIdentityUser user = await userManager.FindByIdAsync(userId);

            var viewModel = new AccountWelcomeVM {
                Score = user.Score
            };

            return(viewModel);
        }