/// <summary> /// 获取特定app在电商中的当前生效的积分扩展信息。 /// </summary> /// <param name="paramDto">查询参数</param> /// <returns></returns> public ResultDTO <UserScoreDTO> GetUserScoreInAppExt(Param2DTO paramDto) { Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.UserScoreDTO> result = new ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.UserScoreDTO>(); UserScoreDTO usDto = new UserScoreDTO(); result.Data = usDto; try { if (paramDto == null) { result.Message = "参数错误,参数不能为空!"; result.ResultCode = 1; return(result); } if (paramDto.UserId == Guid.Empty) { result.Message = "参数错误,appId不能为空!"; result.ResultCode = 1; return(result); } if (paramDto.AppId == Guid.Empty) { result.Message = "参数错误,appId不能为空!"; result.ResultCode = 1; return(result); } var appIsCashForScore = (from ae in AppExtension.ObjectSet() where ae.Id == paramDto.AppId select ae.IsCashForScore).FirstOrDefault(); if (appIsCashForScore == null || appIsCashForScore == false) { usDto.IsCashForScore = false; return(result); } usDto.IsCashForScore = appIsCashForScore; var ssFirst = (from ss in ScoreSetting.ObjectSet() where ss.AppId == paramDto.AppId orderby ss.SubTime descending select ss.ScoreCost).FirstOrDefault(); if (!ssFirst.HasValue) { return(result); } usDto.ScoreCost = ssFirst.Value; int score = Jinher.AMP.BTP.TPS.SignSV.Instance.GiveUserScore(paramDto.UserId, paramDto.AppId); usDto.Score = score; usDto.Money = DecimalExt.ToMoney((decimal)score / usDto.ScoreCost); } catch (Exception ex) { string str = string.Format("ScoreSettingSV.GetUserScoreInAppExt中发生异常,参数AppId:{0},异常信息:{1}", paramDto.AppId, ex); LogHelper.Error(str); result.Message = "服务异常!"; result.ResultCode = 2; } return(result); }
private void GetTotalScoreDatas() { UserScoreDTO userScoreDTO = _practiceController.GetTotalUserScoreByUserID(user.UserID); if (userScoreDTO.FalseAnswer == 0 & userScoreDTO.FalseAnswer == 0 & userScoreDTO.FalseAnswer == 0) { // MessageBox.Show("GET PREMIUM FOR MORE WORDS"); } else { decimal total = userScoreDTO.TrueAnswer + userScoreDTO.FalseAnswer; decimal divide = Decimal.Round((userScoreDTO.TrueAnswer / total), 2); lblTrueScore.Text = userScoreDTO.TrueAnswer.ToString(); lblFalseScore.Text = userScoreDTO.FalseAnswer.ToString(); lblTotalTıme.Text = Decimal.Round(((userScoreDTO.PracticeTime / (decimal)60)), 0).ToString() + " min."; lblSuccesRate.Text = "% " + (divide * 100).ToString(); } // lblTrueScore.Text = userScoreDTO.TrueAnswer.ToString(); // lblFalseScore.Text = userScoreDTO.FalseAnswer.ToString(); // lblTotalTıme.Text = Decimal.Round(((userScoreDTO.PracticeTime / (decimal)60)), 0).ToString() + " min."; // lblSuccesRate.Text = "% " + (divide * 100).ToString(); //} }
public void ReportUserScore_Returns_Success() { //Arrange var username = string.Format("TestUser_20200420033913"); var userscore = new UserScoreDTO(username, 10); // Act var okResult = _controller.report(userscore).Result; var okObjectResult = okResult as OkObjectResult; var val = okObjectResult.Value as ResultDTO; // Assert Assert.IsType <OkObjectResult>(okResult); Assert.IsType <ResultDTO>(okObjectResult.Value); Assert.Equal("Success", val.Status); }
public void ReportUserScore_Returns_Error() { //Arrange var username = string.Format("Not_Exist_User_#$&"); var userscore = new UserScoreDTO(username, 10); // Act var okResult = _controller.report(userscore).Result; var okObjectResult = okResult as OkObjectResult; var val = okObjectResult.Value as ResultDTO; // Assert Assert.IsType <OkObjectResult>(okResult); Assert.IsType <ResultDTO>(okObjectResult.Value); Assert.Equal("Error", val.Status); Assert.Equal("Username Not Exist", val.Data); }
public UserScoreDTO GetTotalUserScoreByUserID(Guid userID) { UserScoreDTO userScoreDTO; string query = @"Select SUM(distinct p.TrueAnswer) as true,SUM(distinct p.FalseAnswer) as false,SUM(distinct p.PracticeTime) as time from [User] u join WordPool w on w.UserID=u.UserID join WordPoolDetail wd on wd.WordPoolID=w.WordPoolID join PracticeDetail pd on wd.WordPoolID=pd.WordPoolID join Practice p on p.PracticeID=pd.PracticeID where u.UserID=@userID group by u.UserID"; h.AddParametersToCommand(new List <SqlParameter>() { new SqlParameter() { ParameterName = "@userID", Value = userID } }); SqlDataReader reader = h.MyExecuteReader(query); reader.Read(); userScoreDTO = new UserScoreDTO(); { if (reader.HasRows) { userScoreDTO.TrueAnswer = (int)reader[0]; userScoreDTO.FalseAnswer = (int)reader[1]; userScoreDTO.PracticeTime = (int)reader[2]; } else { userScoreDTO.TrueAnswer = 0; userScoreDTO.FalseAnswer = 0; userScoreDTO.PracticeTime = 0; } reader.Close(); return(userScoreDTO); } }
public async Task <IActionResult> report(UserScoreDTO request) { var result = await userManager.AddUserScoreAsync(request.UserName, request.Score); return(Ok(result)); }
public async Task DeleteAsync(UserScoreDTO userScore) { var mapper = config.CreateMapper(); repository.Remove(mapper.Map <UserScore>(userScore)); }
public async Task UpdateAsync(UserScoreDTO userScore) { var mapper = config.CreateMapper(); repository.Create(mapper.Map <UserScoreDTO, UserScore>(userScore)); }