Example #1
0
 public TestDefaultParams(
     sbyte sb          = -12,
     byte b            = 12,
     short s           = -1234,
     ushort us         = 1234,
     int i             = -12345,
     uint ui           = 12345,
     long l            = -12345678900L,
     ulong ul          = 12345678900UL,
     string str        = "str",
     float f           = 1.23f,
     double d          = 1.23,
     decimal dc        = 1.23M,
     TestEnum e        = TestEnum.Bar,
     UserScore complex = null,
     bool bo           = true)
 {
     B       = b;
     Sb      = sb;
     S       = s;
     Us      = us;
     I       = i;
     Ui      = ui;
     L       = l;
     Ul      = ul;
     Str     = str;
     F       = f;
     D       = d;
     Dc      = dc;
     Bo      = bo;
     E       = e;
     Complex = complex;
 }
Example #2
0
        public void Mock_RefreshScore(int userId)
        {
            /*
             * Get categories
             * Generate score for each category
             * */
            var categories = this.scoreDataAccess.GetCategories();
            var userScores = new List <UserScore>();
            var random     = new Random();

            foreach (var category in categories)
            {
                var userScore = new UserScore();
                userScore.UserId  = userId;
                userScore.ICMapId = category.Id;
                userScore.Score   = random.Next(40, 100);
                var rndm_inner  = new Random();
                var ionicScores = MockHelper.GetRandomValueCollection(rndm_inner, (double)userScore.Score, 3)
                                  .OrderByDescending(o => o);
                userScore.NeutralScore  = (decimal)ionicScores.FirstOrDefault();
                userScore.PositiveScore = (decimal)ionicScores.Skip(1).FirstOrDefault();
                userScore.NegativeScore = (decimal)ionicScores.Skip(2).FirstOrDefault();
                userScores.Add(userScore);
            }
            this.scoreDataAccess.UpdateUserScore(userScores);
        }
Example #3
0
        public void AddCup(string operationString, int userId)
        {
            Operations operation = (Operations)Enum.Parse(typeof(Operations), operationString);
            UserCup    userCup   = BusinessStructure.Instance.Model.UserCups.First(item => item.UserId == userId);
            UserScore  userScore = BusinessStructure.Instance.Model.UserScores.First(item => item.UserId == userId);

            userScore.Score += 100;
            switch (operation)
            {
            case Operations.Add:
                userCup.AddCup++;
                break;

            case Operations.Diff:
                userCup.DiffCup++;
                break;

            case Operations.Div:
                userCup.DivCup++;
                break;

            case Operations.Mul:
                userCup.MulCup++;
                break;
            }
            BusinessStructure.Instance.Model.SaveChanges();
        }
Example #4
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            MaxAttempts.BindValueChanged(_ => updateAttempts());
            UserScore.BindValueChanged(_ => updateAttempts(), true);
        }
        public TennisGame(MainMenuForm mainMenu)
        {
            InitializeComponent();
            this.mainMenu = mainMenu;
            gameStatus    = GAME_STATUS.IN_GAME;
            UserScore     = 0;
            CompScore     = 0;

            UserScoreLabel.Text = UserScore.ToString();
            CompScoreLabel.Text = CompScore.ToString();

            table = TablePanel.CreateGraphics();

            userRacket = new UserRacket(this);
            compRacket = new CompRacket(this);
            ball       = new Ball(this);

            TablePanel.Controls.Add(userRacket);
            TablePanel.Controls.Add(compRacket);
            TablePanel.Controls.Add(ball);

            userRacket.Show();
            compRacket.Show();
            ball.Show();

            compRacket.Enabled = false;
            ball.Enabled       = false;
        }
Example #6
0
 public void SaveScore(UserScore score)
 {
     if (_scoreTable.AddNew(score))
     {
         _serializer.WriteScores(_scoreTable);
     }
 }
Example #7
0
        public async Task <bool> PostScore(UserScore userScore)
        {
            var stringContent       = new StringContent(_converter.SerializeScore(userScore), System.Text.Encoding.UTF8, "application/json");
            var isSuccessStatusCode = await _httpService.Post(ResourceIdentifier.RatingUri(), stringContent);

            return(isSuccessStatusCode);
        }
Example #8
0
        public async Task <IActionResult> PutUserScore(int id, UserScore userScore)
        {
            if (id != userScore.UserScoreId)
            {
                return(BadRequest());
            }

            _context.Entry(userScore).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserScoreExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #9
0
        //保存加分历史记录,返回加分值,0为保存失败。
        private double SaveScoreRecord(UserScore userScore, BLLTransaction transaction)
        {
            string deltaScoreStr = string.Empty;

            if (userScore.Score > 0)
            {
                deltaScoreStr = string.Format("+{0}", userScore.Score);
            }
            else
            {
                deltaScoreStr = string.Format("{0}", userScore.Score);
            }
            BLLJIMP.Model.WBHScoreRecord srInfo = new BLLJIMP.Model.WBHScoreRecord()
            {
                InsertDate = DateTime.Now,

                ScoreNum     = deltaScoreStr,
                WebsiteOwner = this.userInfo.WebsiteOwner,
                UserId       = this.UserID,
                NameStr      = userScore.RecordTypeString,
                Nums         = userScore.nums,
                RecordType   = userScore.RecordType,
            };

            if (this.Add(srInfo))
            {
                return(userScore.Score);
            }
            return(0);
        }
Example #10
0
        //给用户增加积分(负值为减积分),同时写入积分历史,返回修改的delta分值
        public double UpdateUserScore(UserScore userScore)
        {
            try
            {
                ZentCloud.ZCBLLEngine.BLLTransaction bllTransaction = new ZentCloud.ZCBLLEngine.BLLTransaction();

                //记录加减分历史
                if (userScore.Score != 0)
                {
                    if (SaveScoreRecord(userScore, bllTransaction) == 0)
                    {
                        bllTransaction.Rollback();
                        return(0);
                    }
                }

                userInfo.TotalScore += userScore.Score;
                if (userScore.Score > 0) //减分不计入累计积分
                {
                    userInfo.HistoryTotalScore += userScore.Score;
                }
                if (this.Update(userInfo, string.Format(" TotalScore={0},HistoryTotalScore={1}", userInfo.TotalScore, userInfo.HistoryTotalScore), string.Format(" AutoID={0}", userInfo.AutoID), bllTransaction) < 1) //更改用户积分
                {
                    bllTransaction.Rollback();
                    return(0);
                }

                bllTransaction.Commit();
                return(userScore.Score);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Example #11
0
        public async Task <string> SaveUserScore(IUserScore userScore)
        {
            if (userScore == null)
            {
                throw new ArgumentNullException(nameof(userScore));
            }

            string result = string.Empty;

            var newUserScore = new UserScore {
                UserId      = userScore.UserId,
                Score       = userScore.Score,
                CategoryId  = userScore.CategoryId,
                DateCreated = DateTime.UtcNow,
                DateTaken   = DateTime.Now,
            };

            try
            {
                await this._dataContext.UserScores.AddAsync(newUserScore);

                await this._dataContext.SaveChangesAsync();
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                result = $"{e.Message}";
            }

            return(result);
        }
Example #12
0
        public async Task Delete(int idWine, string idUserScore)
        {
            UserScore userScore = _context.UserScores.ToList().Last(x => x.AppUserId == idUserScore && x.WineId == idWine);

            _context.Remove(userScore);
            await _context.SaveChangesAsync();
        }
Example #13
0
        public async Task AwardPoints(DiscordUser discordUser, int points = 1)
        {
            // Get user
            var knownUser = await _userService.GetOrCreateKnownUserForDiscordUser(discordUser);

            // Get current score (if present)
            var userScore = await _selfcareDb.UserScores.Where(us => us.KnownUser.Id == knownUser.Id)
                            .FirstOrDefaultAsync();

            // If user does not have a score, then create it
            if (userScore == null)
            {
                userScore = new UserScore
                {
                    KnownUser = knownUser,
                    Category  = HydrationCategory,
                    Score     = 0
                };

                _selfcareDb.UserScores.Add(userScore);
            }

            // give points
            userScore.Score += points;

            // Save changes
            await _selfcareDb.SaveChangesAsync();
        }
Example #14
0
    public void SubmitHighScore()
    {
        this.initialsCanvas.SubmitButton.gameObject.SetActive(false);
        this.isEnteringInitials = false;

        string name = this.initialsCanvas.FirstInitial.Text.Replace("_", " ") +
                      this.initialsCanvas.MiddleInitial.Text.Replace("_", " ") +
                      this.initialsCanvas.LastInitial.Text.Replace("_", " ");

        UserScore newHighScore = new UserScore {
            rank     = this.newScoreIndex,
            username = name,
            score    = (int)Globals.Score
        };

        Globals.HighScores.Insert(this.newScoreIndex, newHighScore);
        Globals.HighScores.RemoveAt(Globals.HighScores.Count - 1);

        #if PERSIST_SCORES
        Globals.SaveHighScores();
        #endif

        #if OFFLINE_MODE && !CABINET_MODE
        this.postToTwitterMenu.SetActive(true);
        this.yesPostButton.Select();
        #else
        Invoke("AllowQuit", 0.5f);
        #endif
    }
Example #15
0
        private async Task SubmitAction()
        {
            List <UserScore> userScore = await _dataService.GetRating(movieID, cinemaID);

            string userId = null;

            if (Device.RuntimePlatform != Device.UWP)
            {
                userId = Hardware.DeviceId;
            }

            UserScore score = new UserScore
            {
                IdUser       = 0,
                IdStringUser = userId,
                IdCinema     = cinemaID,
                IdMovie      = movieID,
                Screen       = (long)ScreenRating,
                Seat         = (long)SeatsRating,
                Sound        = (long)SoundRating,
                Popcorn      = (long)SnacksRating,
                Cleanliness  = (long)CleanlinessRating
            };

            if (!await _dataService.PostScore(score))
            {
                Mvx.Resolve <IUserDialogs>().Alert("You have already scored this show!");
            }
            //else
            //{
            //    Mvx.Resolve<IUserDialogs>().Alert("Thank you for scoring this show!");
            //}

            await _navigationService.Close(this);
        }
Example #16
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(UserScore model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserScore(");
            strSql.Append(" UserID,Score,ScoreType,CreateUser,CreateTime,UpdateUser,UpdateTIme,IsDelete )");
            strSql.Append(" values (");
            strSql.Append("@UserID,@Score,@ScoreType,@CreateUser,@CreateTime,@UpdateUser,@UpdateTIme,@IsDelete)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID",     model.UserID),
                new SqlParameter("@Score",      model.Score),
                new SqlParameter("@ScoreType",  model.ScoreType),
                new SqlParameter("@CreateUser", model.CreateUser),
                new SqlParameter("@CreateTime", model.CreateTime),
                new SqlParameter("@UpdateUser", model.UpdateUser),
                new SqlParameter("@UpdateTIme", model.UpdateTIme),
                new SqlParameter("@IsDelete",   model.IsDelete),
            };

            object obj = SqlHelper.GetSingle(strSql.ToString(), CommandType.Text, parameters);

            return(obj == null ? 0 : Convert.ToInt32(obj));
        }
 public void SetData()
 {
     if (UserScore <int> .GetFinished())
     {
         for (int i = 1; i < 11; i++)              //ricerco la posizione in cui salvarlo
         {
             if (PlayerPrefs.HasKey(i.ToString())) //ho già un punteggio in questa posizione
             {
                 curr_name = PlayerPrefs.GetString(i.ToString());
                 if (PlayerPrefs.HasKey(curr_name))
                 {
                     curr_score = PlayerPrefs.GetInt(curr_name);
                     if (score > curr_score)
                     {
                         //inizia lo shift in basso
                         ShiftLow(i);
                         //salva posizione
                         PlayerPrefs.SetString(i.ToString(), pName);
                         PlayerPrefs.SetInt(pName, score);   //assegno direttamente al nome il punteggio => se >10 non salvo
                         //esci dal ciclo
                         break;
                     }
                 }
             }
             else //non ho salvato ancora nessun punteggio in questa posizione
             {
                 //posso assegnare il punteggio in questa posizione
                 PlayerPrefs.SetString(i.ToString(), pName);
                 PlayerPrefs.SetInt(pName, score);
                 break;
             }
         }
     }
 }
        public async Task <IHttpActionResult> SetupData()
        {
            try
            {
                var user = db.Users.First(x => x.Email.Equals("*****@*****.**"));
                var post = new NewsPost
                {
                    Body = "nvad jashjavh  biaev ",
                    //Id = 1,
                    NewsDate = DateTime.Now,
                    NewsType = "Politics",
                    //Scores = new List<UserScore> { new UserScore { Score = 1, User = user, Post = this } },
                    User  = user,
                    Title = "BlaBla"
                };
                db.NewsPosts.Add(post);
                db.SaveChanges();
                //db.NewsPosts.AddOrUpdate(p => p.Id, post);
                //db.SaveChanges();

                var score = new UserScore {
                    Score = 1, User = user, NewsPost = post
                };
                //db.UserScores.AddOrUpdate(score);
                //db.SaveChanges();
            }
            catch (Exception e) {
                Console.WriteLine(e);
            }
            return(Ok());
        }
    public IEnumerator PostScoreRestAPI(int newScore)
    {
        UserScore userScore = new UserScore {
            userName = PlayerPrefs.GetString("username", string.Empty), score = newScore
        };
        string dataJson = JsonUtility.ToJson(userScore);

        Debug.Log("user score json = " + dataJson);
        UnityWebRequest request = UnityWebRequest.Post(restApiUrl, dataJson);

        request.method = "POST";
        request.SetRequestHeader("accept", "application/json; charset=UTF-8");
        request.SetRequestHeader("content-type", "application/json; charset=UTF-8");
        yield return(request.SendWebRequest());

        if (request.isNetworkError || request.isHttpError)
        {
            Debug.Log(request.error);
            if (request.responseCode == 404)
            {
                Debug.Log("Username not found (user has not registered with the leaderboard service)");
            }
            else if (request.responseCode == 405)
            {
                Debug.Log("Invalid Username supplied");
            }
        }
        else
        {
            Debug.Log("score update complete!");
        }
    }
Example #20
0
        public void Add_Should_Add_The_Score_And_Return_Top_5_Of_The_Scores()
        {
            // Arrange
            var fakeScore = new UserScore
            {
                Id     = 1,
                UserId = 1,
                Score  = 100
            };
            var fakeScoreViewModel = new UserScoreViewModel
            {
                Id     = 1,
                UserId = 0,
                Score  = 100
            };

            _mockRepo.Setup(repo => repo.Add(fakeScore, 1));
            _mockRepo.Setup(repo => repo.IncreaseScore(fakeScore.Score, fakeScore.UserId));
            _mockRepo.Setup(repo => repo.GetTopRanks(It.IsAny <UserScore>())).Returns(_fakeRankList.Where(x => x.Email != "You").ToList());


            // Act
            var methodResult = _mockController.Add(fakeScoreViewModel);

            // Assert
            var testResult = methodResult.Result as OkObjectResult;

            Assert.Equal(JsonConvert.SerializeObject(_fakeRankList), JsonConvert.SerializeObject(testResult.Value));
        }
Example #21
0
    // score Canvas 에서 보여주는 내용
    // failure/success canvas에서 score 결과값 데이터베이스 업데이트 후
    // UserEasyScore,UserHardScore 로컬 저장 변수에 다시 각각 입력
    public void GetUserScoreData() // intro Scene 에서 젤 처음 로딩
    {
        UserScore userScore = new UserScore();

        FirebaseDatabase.DefaultInstance.GetReference("users")
        .Child(LoginCanvas.user.UserId).Child("_score")
        .GetValueAsync().ContinueWith(task =>
        {
            if (task.IsFaulted)
            {
                UserEasyScore = -1;
                UserHardScore = -1;
                Debug.Log("유저 score 데이타 참조 실패");
            }
            else if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;
                userScore             = JsonUtility.FromJson(snapshot.GetRawJsonValue(),
                                                             typeof(UserScore)) as UserScore;

                UserEasyScore = userScore.easy;
                UserHardScore = userScore.hard;
            }
        });
    }
        public async Task <IActionResult> SinglePlayer()
        {
            var response = await DbContext.Set <UserScore>().FirstOrDefaultAsync(n => n.UserId == User.FindFirstValue(ClaimTypes.NameIdentifier));

            if (response == null)
            {
                var record = new UserScore
                {
                    UserId      = User.FindFirstValue(ClaimTypes.NameIdentifier),
                    TimeStamp   = DateTime.UtcNow,
                    EvaCost     = 10,
                    NewtonCost  = 50,
                    JobsCost    = 100,
                    EvaCount    = 0,
                    NewtonCount = 0,
                    JobsCount   = 0,
                    Score       = 1
                };
                DbContext.Add(record);
                DbContext.SaveChanges();
                response = record;
            }
            var model = new SinglePlayerViewModel
            {
                EvaCost     = response.EvaCost,
                EvaCount    = response.EvaCount,
                JobsCost    = response.JobsCost,
                JobsCount   = response.JobsCount,
                NewtonCost  = response.NewtonCost,
                NewtonCount = response.NewtonCount,
                Score       = response.Score
            };

            return(View(model));
        }
Example #23
0
        public async Task <ActionResult <UserScore> > PostUserScore(UserScore userScore)
        {
            _context.UserScore.Add(userScore);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUserScore", new { id = userScore.UserScoreId }, userScore));
        }
        public async Task <IEnumerable <UserScore> > GetUserScoreWithUserAsync(Guid quizId)
        {
            var result = await _context.UserScores.Include(e => e.ApplicationUser)
                         .GroupBy(e => new { e.QuizId, e.ApplicationUserId, e.MaxScore })
                         .Select(e => new { Score = e.Max(x => x.Score), User = e.Key.ApplicationUserId, maxScore = e.Key.MaxScore, quiz = e.Key.QuizId }).Where(e => e.quiz == quizId)
                         .OrderByDescending(e => e.Score)
                         .ToDictionaryAsync(e => new UserScore {
                Score = e.Score, ApplicationUserId = e.User, MaxScore = e.maxScore
            });

            List <UserScore> userScores = new List <UserScore>();

            foreach (var item in result)
            {
                UserScore userScore = new UserScore()
                {
                    ApplicationUserId = item.Value.User,
                    Score             = item.Value.Score,
                    MaxScore          = item.Value.maxScore
                };
                userScores.Add(userScore);
            }
            //await _context.UserScores.Include(p => p.ApplicationUser).Where(p => p.QuizId == quizId).OrderByDescending(p => p.Score).Take(10).ToListAsync()
            return(userScores);
        }
        public bool PostScoreCard(UserScore userScore)
        {
            try
            {
                //Create the SQL Query for inserting an UserAnswers

                string deleteStr     = "Delete from userscore where UserID =" + userScore.UserID;
                string insertUserAns = String.Format("Insert into UserScore (UserID,Aptitude,Reasoning,Technology) Values('{0}', '{1}', '{2}', {3} )"
                                                     , userScore.UserID, userScore.Aptitude, userScore.Reasoning, userScore.Technology);

                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    connection.Open();
                    SqlCommand command             = new SqlCommand(deleteStr, connection);
                    SqlCommand commandInsert       = new SqlCommand(insertUserAns, connection);
                    var        commandResult       = command.ExecuteScalar();
                    var        commandInsertResult = commandInsert.ExecuteScalar();
                }
            }
            catch (Exception ex)
            {
                throw ex;
                //there was a problem executing the script
            }
            return(true);
        }
Example #26
0
 public static UserScore getInstance()
 {
     if (instance == null)
     {
         instance = new UserScore();
     }
     return(instance);
 }
Example #27
0
        public void AddScore(UserScore score)
        {
            var instance = Instantiate(UserScoreUiPrefab, Content);
            var ui       = instance.GetComponent <UserScoreUi>();

            ui.Score = score;
            _scoreObjects.Add(ui);
        }
Example #28
0
 private void CreateScoreRow(UserScore score)
 {
     var go = Instantiate(_scorePrefab);
     go.transform.parent = _contenTransform;
     var scoreRow = go.GetComponent<ScoreRow>();
     scoreRow.Init(score, _scores.Count + 1);
     _scores.Add(scoreRow);
 }
Example #29
0
 private int compareTo(UserScore x, UserScore y)
 {
     int result = y.score - x.score;
     if (result == 0)
     {
         result = y.userid - x.userid;
     }
     return result;
 }
Example #30
0
 public void SetScore(string userid, string username, string scoreType, int value)
 {
     if (userScores == null) userScores = new Dictionary<string, UserScore>();
     if (!userScores.ContainsKey(userid))
     {
         userScores[userid] = new UserScore() { name = username, scores = new Dictionary<string, int>() };
     }
     userScores[userid].scores[scoreType] = value;
 }
Example #31
0
        public ActionResult Rebirth(int pid, int count)
        {
            var product = ur.GetProductByUser(pid, CurrentUser.Id);
            int seedId  = 800001;

            if (product != null)
            {
                product.TotalCount -= count;
                product.UpdateTime  = DateTime.Now;
                ur.UpdateUserProduct(product);

                var seed = ur.GetProductByUser(seedId, CurrentUser.Id);
                if (seed == null || seed.Id != seedId)
                {
                    seed = new UserProduct()
                    {
                        ProductId   = seedId,
                        TotalCount  = count,
                        FrozenCount = 0,
                        UserId      = CurrentUser.Id,
                        UpdateTime  = DateTime.Now,
                        CreateTime  = DateTime.Now
                    };
                    ur.CreateUserProduct(seed);
                }
                else
                {
                    seed.TotalCount += count;
                    seed.UpdateTime  = DateTime.Now;
                    ur.UpdateUserProduct(seed);
                }
                var pr = new ProductRebirth
                {
                    ProductId    = pid,
                    UserId       = CurrentUser.Id,
                    RebirthCount = count,
                    SeedCount    = count,
                    ChargeFee    = 0,
                    CreateTime   = DateTime.Now
                };
                new ProductRebirthRepository().Create(pr);
                var m     = mr.GetTodayProductMarket(pid);
                var score = new UserScore
                {
                    TypeId     = (int)ScoreType.果实重生,
                    UserId     = CurrentUser.Id,
                    Status     = 1,
                    ChargeFee  = 0,
                    CreateTime = DateTime.Now,
                    Score      = m.CurrentPrice * count
                };
                new UserScoreRepository().Create(score);
            }

            return(Content("1"));
        }
Example #32
0
        public void OnScoreChanged(UserScore userScore)
        {
            var indexToUpdate = _viewModel.CurrentGame.scores.FindIndex(s => s.userId == userScore.userId);

            if (indexToUpdate >= 0)
            {
                _viewModel.CurrentGame.scores[indexToUpdate] = userScore;
            }
            _viewModel.onScoreChangedListener(_viewModel.CurrentGame);
        }
Example #33
0
        private void AddScore(decimal score, UserAction reason)
        {
            var userScore = new UserScore
            {
                Timestamp  = SystemTime.Now(),
                Score      = score,
                ActionType = reason,
            };

            UserScores.Add(userScore);
        }
Example #34
0
        public ActionResult Withdraw(UserWithdraw withdraw, string mcode)
        {
            if (!new SmsRepository().CheckSms(CurrentUser.Phone, mcode, "WITHDRAW"))
            {
                ModelState.AddModelError("Withdraw", "请确认短信验证码");
                var model = new UserWithdrawViewModel();
                model.User      = CurrentUser;
                model.Withdraws = ur.GetWithdrawHistoryByUser(CurrentUser.Id);
                return(View(model));
            }
            decimal chargeFee = 0M;

            if (withdraw.Amount >= 100 && withdraw.Amount < 200)
            {
                chargeFee = withdraw.Amount * 0.03M;
            }
            else if (withdraw.Amount >= 200 && withdraw.Amount < 500)
            {
                chargeFee = withdraw.Amount * 0.029M;
            }
            else if (withdraw.Amount >= 500 && withdraw.Amount < 1000)
            {
                chargeFee = withdraw.Amount * 0.025M;
            }
            else if (withdraw.Amount >= 1000)
            {
                chargeFee = withdraw.Amount * 0.02M;
            }
            withdraw.ChargeFee  = chargeFee;
            withdraw.UserId     = CurrentUser.Id;
            withdraw.Status     = 0;
            withdraw.CreateTime = DateTime.Now;
            var bank = ur.GetBankAccount(CurrentUser.Id);

            if (bank != null)
            {
                withdraw.Bank        = bank.Bank;
                withdraw.AccountName = bank.AccountName;
                withdraw.AccountNum  = bank.AccountNum;
                new UserWithdrawRepository().Create(withdraw);

                var score = new UserScore
                {
                    UserId     = CurrentUser.Id,
                    TypeId     = (int)ScoreType.提现,
                    Status     = 0,
                    ChargeFee  = chargeFee,
                    Score      = withdraw.Amount,
                    CreateTime = DateTime.Now
                };
                new UserScoreRepository().Create(score);
            }
            return(RedirectToAction("Withdraw"));
        }
Example #35
0
 public override bool TakeAction()
 {
     var cache = new ShareCacheStruct<UserScore>();
     var ranking = cache.Find(m => m.username == _username);
     if (ranking == null)
     {
         var user = new User() { userid = (int)cache.GetNextNo(), nickname = _username };
         new PersonalCacheStruct<User>().Add(user);
         ranking = new UserScore();
         ranking.userid = user.userid;
         ranking.username = _username;
         ranking.score = _score;
         cache.Add(ranking);
     }
     else
     {
         ranking.username = _username;
         ranking.score = _score;
     }
     return true;
 }
Example #36
0
 public void Init(UserScore score, int number)
 {
     _score.text = string.Format("{0}. {1} - {2}", number, score.Name, score.Score);
 }