public async Task <IActionResult> RemoveScore(int id, UserScoreModel scoreModel) { var user = await _userRepository.GetAsync(id); if (user.Balance >= scoreModel.Score) { if (scoreModel.ScoreDev > 0) { await _userScoreRepository.AddAsync(new UserTransaction { Score = -scoreModel.ScoreDev, UserId = id, Type = TransactionType.AdminMinus, CreatedAt = DateTime.UtcNow }); //var transactions = await _userScoreRepository.GetAllAsync(user.Id); //var sum = transactions.Sum(p => p.Score); user.Balance -= scoreModel.ScoreDev;// sum; } await _userRepository.Update(user); } return(RedirectToAction("Index", "User", new { pageIndex = scoreModel.PageIndex, searchString = scoreModel.SearchString })); }
//获取用户登录提交和得分情况 public static UserScoreModel GetUserScore(string userId) { UserScoreModel model = new UserScoreModel(); string sql = string.Format(@"SELECT [IsSubmit] ,[CreateTime] ,[Score] ,[UpdateTime] FROM[WaterSupplySecurity].[dbo].[UserScore] where UserID = {0}", userId); model = DataAcccessHelper.QueryFirstOrDefault <UserScoreModel>(sql); return(model); }
public async Task <IActionResult> Put([FromHeader] string UserId) { var userList = _context.Users.Where(u => u.BadgeBookId == UserId).ToList(); Dictionary <string, string> dict = new Dictionary <string, string> { { "Javascript", "7th" } }; UserScoreModel user = new UserScoreModel { UserId = userList.First().Email, UserRank = dict }; return(Ok(user)); }
private async Task TriviaEnding() { var scores = _scoreKeeper.Scores; // Exit early if no scores exist if (scores.Count <= 0) { return; } // Find the winner and give them a lifetime win UserScoreModel winner = scores.OrderByDescending(x => x.Score).First(); _lifetimeScoreService.AddLifetimeWin(winner.Id); // Add each user's score to their lifetime record foreach (UserScoreModel score in scores) { _lifetimeScoreService.AddLifetimeScore(score.Id, score.Score); } // Show the scores to the channel await PrintScores(_scoreKeeper.Scores); }
//获取用户登录提交和得分情况 public static UserScoreModel GetUserScore(string userId) { UserScoreModel model = new UserScoreModel(); return(model); }
public IActionResult PostScores([FromBody] UserScoreModel scores) { return(Ok()); }