Esempio n. 1
0
        public static int UPointAllSel(int iUserID)
        {
            UserPoints upObject = UserPointsDAL.UserPointsSelect(iUserID);
            int        iPoints  = upObject.Points + upObject.GiftPoints;

            return(iPoints);
        }
Esempio n. 2
0
        public async Task ClearPrayersForUserAsync(string uuid, CancellationToken ct = default)
        {
            UserPoints userpoints = await _context.UserPoints.FindAsync(uuid);

            userpoints.Prayers           = 0;
            userpoints.MeaningfulPrayers = 0;
            await _context.SaveChangesAsync();
        }
        public async Task <IActionResult> UpdatePointsForUser(string uuid, [FromBody] UserPoints points, CancellationToken ct = default)
        {
            if (!AuthenticationUtilities.IsSameUserOrPrivileged(User, uuid))
            {
                return(Unauthorized("You do not have access to this endpoint."));
            }

            return(Ok(await _userRepository.UpdatePointsForUserAsync(uuid, points, ct)));
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int    iUserID   = GetUserID();
            string sRes      = YeePayBuy.QuickYeePaySubmit();
            string sTranIP   = ProvideCommon.GetRealIP();
            string sFromUrl  = Request.Url.ToString();
            char   cTranFrom = 't';

            if ("4" == sRes)
            {
                cTranFrom = 'y';
                YeePayBuy.LastOfPayLog(sTranIP, cTranFrom, sFromUrl);
                if (iUserID > 999)
                {
                    UserPoints upObject = UserPointsBLL.UPointsSel(iUserID);
                    SetPoints(upObject.Points);
                }
                Response.Write("SUCCESS");
                return;
            }
            else
            {
                YeePayBuy.LastOfPayLog(sTranIP, cTranFrom, sFromUrl);
                string[] sARes = sRes.Split('|');
                string   sUrl  = string.Empty;
                if ("1" == sARes[0])
                {
                    sUrl = string.Format("PayGSucc.aspx?TranID={0}&gn={1}&type=q", sARes[1], sARes[2]);
                    Response.Redirect(sUrl, true);
                }
                else if ("3" == sARes[0])
                {
                    //sMsg = "<script>alert('武林币充值成功!游戏充值失败!请进入武林币兑换页面进行兑换!');</script>";
                    Response.Redirect("PayPErr.aspx?err=101");
                }
                else if ("2" == sARes[0])
                {
                    //sMsg = "<script>alert('提交订单失败!请联系客服!');</script>";
                    Response.Redirect(string.Format("PayPErr.aspx?err=102&code={0}", sRes));
                }
                else if ("0" == sARes[0])
                {
                    //充值失败,原因见sRes[1]
                    //sMsg = "<script>alert('请稍等查看余额,如有问题请联系客服!');</script>";
                    Response.Redirect("PayPErr.aspx?err=110");
                }
                else
                {
                    sMsg = string.Format("<script>alert('{0}');</script>", sRes);
                }
            }
        }
Esempio n. 5
0
        public IHttpActionResult PostSetPoints([FromBody] UserPoints userPoints)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!repository.TryUpdatePoints(userPoints.Id, userPoints.Points))
            {
                return(BadRequest(string.Format("Cannot update points. User with id {0} does not exist", userPoints.Id)));
            }

            return(Ok());
        }
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Title == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Title");
     }
     if (Message == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Message");
     }
     if (UserPoints != null)
     {
         UserPoints.Validate();
     }
 }
Esempio n. 7
0
        public async Task <UserPoints> UpdatePointsForUserAsync(string uuid, UserPoints points, CancellationToken ct = default)
        {
            UserPoints userpoints = await _context.UserPoints
                                    .AsNoTracking()
                                    .FirstOrDefaultAsync(u => u.UserUUID == uuid);

            if (userpoints != null)
            {
                userpoints = points;
                _context.Update(userpoints);
                await _context.SaveChangesAsync();
            }

            return(userpoints ?? null);
        }
Esempio n. 8
0
        public void SaveEveryFiveMinutes()
        {
            using (ConsoleContext db = new ConsoleContext())
            {
                lock (UserPoints)
                {
                    foreach (var kvp in UserPoints)
                    {
                        var user = db.tblUser.Include(i => i.Points).FirstOrDefault(x => x.Name == kvp.Key);
                        if (user == null)
                        {
                            //Make
                            user = new User()
                            {
                                Name = kvp.Key
                            };
                            db.tblUser.Add(user);
                            db.SaveChanges();
                            user = db.tblUser.Include(i => i.Points).FirstOrDefault(x => x.Name == kvp.Key);
                        }

                        var points = user.Points.FirstOrDefault(x => x.Date == DateTime.Now.Date);
                        if (points == null)
                        {
                            //Make
                            var po = new Point()
                            {
                                Date = DateTime.Now.Date, Count = kvp.Value, User = user
                            };
                            db.tblPoint.Add(po);
                            db.SaveChanges();

                            user.Points.Add(po);
                        }
                        else
                        {
                            //Modify
                            points.Count += kvp.Value;
                        }
                        db.SaveChanges();
                    }
                    UserPoints.Clear();
                }
            }
        }
Esempio n. 9
0
        public async Task AssingPointToPlayer(UserPoints userPoints, GameType gameType)
        {
            var currentPlayerRanking = GetPlayerRankingInGame(userPoints.UserId, gameType);

            if (currentPlayerRanking == null)
            {
                currentPlayerRanking = new Ranking
                {
                    GameType = gameType,
                    UserId   = userPoints.UserId,
                    Points   = userPoints.Points
                };
            }
            else
            {
                currentPlayerRanking.Points += userPoints.Points;
            }

            await rankingRepository.SaveRanking(currentPlayerRanking);
        }
        public RankingHelper()
        {
            int      id       = 1;
            string   userId   = "user_id";
            GameType gameType = GameType.KalamburyGame;
            int      points   = 100;

            ranking = new Ranking
            {
                Id       = id,
                UserId   = userId,
                GameType = gameType,
                Points   = points
            };

            userPoints = new UserPoints {
                UserId = userId,
                Points = points
            };
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sRes      = YeePayBuy.YeePaySubmit();
            string sTranIP   = ProvideCommon.GetRealIP();
            string sFromUrl  = Request.Url.ToString();
            char   cTranFrom = 't';

            if ("4" == sRes)
            {
                int iUserID = GetUserID();
                cTranFrom = 'y';
                YeePayBuy.LastOfPayLog(sTranIP, cTranFrom, sFromUrl);
                if (iUserID > 999)
                {
                    UserPoints upObject = UserPointsBLL.UPointsSel(iUserID);
                    SetPoints(upObject.Points);
                }
                Response.Write("SUCCESS");
                return;
            }
            else
            {
                YeePayBuy.LastOfPayLog(sTranIP, cTranFrom, sFromUrl);
                string[] sARes = sRes.Split('|');
                if ("1" == sARes[0])
                {
                    Response.Redirect("PayPSucc.aspx?TranID=" + sARes[1]);
                }
                else if ("2" == sARes[0])
                {
                    //sMsg = "<script>alert('提交订单失败!请联系客服!');location.href='default.aspx';</script>";
                    Response.Redirect("PayPErr.aspx?err=101");
                }
                else if ("0" == sARes[0])
                {
                    //sMsg = "<script>alert('请稍等查看余额,如有问题请联系客服!');location.href='default.aspx';</script>";
                    Response.Redirect("PayPErr.aspx?err=110");
                }
            }
        }
Esempio n. 12
0
        public void setcookies(string sAccount, int iUserID)
        {
            Crypto3DES DesObject = new Crypto3DES();

            DesObject.Key = sDESKey;
            Encoding enc = Encoding.GetEncoding("UTF-8");

            Response.Cookies["UserID"].Value      = DesObject.Encrypt3DES(iUserID.ToString());
            Response.Cookies["UserID"].Expires    = DateTime.Now.AddDays(1);
            Response.Cookies["Account"].Value     = HttpUtility.UrlEncode(sAccount, enc);
            Response.Cookies["Account"].Expires   = DateTime.Now.AddDays(1);
            Response.Cookies["logintime"].Value   = DateTime.Now.ToString();
            Response.Cookies["logintime"].Expires = DateTime.Now.AddDays(1);
            UserPoints upObject    = UserPointsBLL.UPointsSel(iUserID);
            int        iPoints     = upObject.Points;
            int        iGiftPoints = upObject.GiftPoints;

            SetPoints(iPoints + iGiftPoints);
            string sLoginInfo = GetUserLogin(iUserID);

            SetLogin(sLoginInfo);
        }
        public async Task <ActionResult> AddPointsToPlayer(UserPoints userPoints)
        {
            await rankingService.AssingPointToPlayer(userPoints, GameType);

            return(Ok());
        }
 public UserPointsModel Build(UserPoints obj)
 {
     throw new NotImplementedException();
 }
Esempio n. 15
0
        public static UserPoints UPointsSel(int iUserID)
        {
            UserPoints upObject = UserPointsDAL.UserPointsSelect(iUserID);

            return(upObject);
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            string command = string.Empty;

            char[,] gameField     = InitializeGameBoard();
            char[,] minesPosition = InitializeMines();
            int  counter                            = 0;
            bool isMineFound                        = false;
            List <UserPoints> users                 = new List <UserPoints>(6);
            int       row                           = 0;
            int       column                        = 0;
            bool      isGameInBeignState            = true;
            const int MaxPoints                     = 35;
            bool      isGameFinishedWithNoMineFound = false;

            do
            {
                if (isGameInBeignState)
                {
                    Console.WriteLine("Hajde da igraem na “Mini4KI”. Probvaj si kasmeta da otkriesh poleteta bez mini4ki." +
                                      " Komanda 'top' pokazva klasiraneto, 'restart' po4va nova igra, 'exit' izliza i hajde 4ao!");
                    DrawGameBoard(gameField);
                    isGameInBeignState = false;
                }

                Console.Write("Daj red i kolona : ");
                command = Console.ReadLine().Trim();
                if (command.Length >= 3)
                {
                    if (int.TryParse(command[0].ToString(), out row) &&
                        int.TryParse(command[2].ToString(), out column) &&
                        row <= gameField.GetLength(0) && column <= gameField.GetLength(1))
                    {
                        command = "turn";
                    }
                }

                switch (command)
                {
                case "top":
                    PrintUserRatng(users);
                    break;

                case "restart":
                    gameField     = InitializeGameBoard();
                    minesPosition = InitializeMines();
                    DrawGameBoard(gameField);
                    isMineFound        = false;
                    isGameInBeignState = false;
                    break;

                case "exit":
                    Console.WriteLine("4a0, 4a0, 4a0!");
                    break;

                case "turn":
                    if (minesPosition[row, column] != '*')
                    {
                        if (minesPosition[row, column] == '-')
                        {
                            SetAdjacentMinesCount(gameField, minesPosition, row, column);
                            counter++;
                        }

                        if (MaxPoints == counter)
                        {
                            isGameFinishedWithNoMineFound = true;
                        }
                        else
                        {
                            DrawGameBoard(gameField);
                        }
                    }
                    else
                    {
                        isMineFound = true;
                    }
                    break;

                default:
                    Console.WriteLine("\nGreshka! nevalidna Komanda\n");
                    break;
                }

                if (isMineFound)
                {
                    DrawGameBoard(minesPosition);
                    Console.Write("\nHrrrrrr! Umria gerojski s {0} to4ki. " +
                                  "Daj si niknejm: ", counter);
                    string     username = Console.ReadLine();
                    UserPoints t        = new UserPoints(username, counter);
                    if (users.Count < 5)
                    {
                        users.Add(t);
                    }
                    else
                    {
                        for (int i = 0; i < users.Count; i++)
                        {
                            if (users[i].Points < t.Points)
                            {
                                users.Insert(i, t);
                                users.RemoveAt(users.Count - 1);
                                break;
                            }
                        }
                    }

                    users.Sort((UserPoints r1, UserPoints r2) => r2.Name.CompareTo(r1.Name));
                    users.Sort((UserPoints r1, UserPoints r2) => r2.Points.CompareTo(r1.Points));
                    PrintUserRatng(users);

                    gameField          = InitializeGameBoard();
                    minesPosition      = InitializeMines();
                    counter            = 0;
                    isMineFound        = false;
                    isGameInBeignState = true;
                }

                if (isGameFinishedWithNoMineFound)
                {
                    Console.WriteLine("\nBRAVOOOS! Otvri 35 kletki bez kapka kryv.");
                    DrawGameBoard(minesPosition);
                    Console.WriteLine("Daj si imeto, batka: ");
                    string     username   = Console.ReadLine();
                    UserPoints userPoints = new UserPoints(username, counter);
                    users.Add(userPoints);
                    PrintUserRatng(users);
                    gameField     = InitializeGameBoard();
                    minesPosition = InitializeMines();
                    counter       = 0;
                    isGameFinishedWithNoMineFound = false;
                    isGameInBeignState            = true;
                }
            }while (command != "exit");

            Console.WriteLine("Made in Bulgaria - Uauahahahahaha!");
            Console.WriteLine("AREEEEEEeeeeeee.");
            Console.Read();
        }