예제 #1
0
        internal WorldScore UpdateWholeEntry(FirstEntry item)
        {
            if (item.UId != 0)
            {
                using (bnbEntities ctx = new bnbEntities())
                {
                    User chkUser = ctx.User.Where(x => x.UId == item.UId).FirstOrDefault();

                    if (chkUser != null)
                    {
                        chkUser.BallCount = item.BallCount;
                        chkUser.LLimit    = item.LLimit;
                        chkUser.Score     = item.Score;
                        chkUser.TSpeed    = item.TSpeed;
                        chkUser.Version   = item.Version;
                        chkUser.Stages    = item.Stages;
                        chkUser.Starts    = item.Stars;
                        if (!string.IsNullOrEmpty(item.Location))
                        {
                            chkUser.Location = item.Location;
                        }
                        if (!string.IsNullOrEmpty(item.FbId))
                        {
                            chkUser.FbId = item.FbId;
                        }
                        chkUser.RankScore = CalculateRankScore(chkUser);
                        ctx.SaveChanges();
                    }
                }
            }
            return(GetTopTen(item.UId));
        }
예제 #2
0
 public void FixRanks()
 {
     using (bnbEntities bnbEntities = new bnbEntities())
     {
         List <User> list = bnbEntities.User.ToList <User>();
         foreach (User current in list)
         {
             int value = this.CalculateRankScore(current);
             current.RankScore = new int?(value);
             bnbEntities.SaveChanges();
         }
     }
 }
예제 #3
0
        internal WorldScore WholeEntry(FirstEntry item)
        {
            if (item.UId == 0)
            {
                using (bnbEntities ctx = new bnbEntities())
                {
                    User chkUser = null;
                    if (!string.IsNullOrEmpty(item.FbId))
                    {
                        var fbCheck = ctx.User.Where(x => x.FbId == item.FbId).FirstOrDefault();
                        if (fbCheck != null)
                        {
                            chkUser = fbCheck;
                        }
                    }



                    if (chkUser == null)
                    {
                        var NameCheck = ctx.User.Where(x => x.Name == item.Name).FirstOrDefault();
                        if (NameCheck != null)
                        {
                            chkUser = NameCheck;
                        }


                        if (chkUser == null)
                        {
                            User newEnt = new User();
                            newEnt.Name      = item.Name;
                            newEnt.Guid      = item.Guid;
                            newEnt.BallCount = item.BallCount;
                            newEnt.LLimit    = item.LLimit;
                            newEnt.Score     = item.Score;
                            newEnt.TSpeed    = item.TSpeed;
                            newEnt.Version   = item.Version;
                            newEnt.Stages    = item.Stages;
                            newEnt.Starts    = item.Stars;
                            if (!string.IsNullOrEmpty(item.Location))
                            {
                                newEnt.Location = item.Location;
                            }
                            if (!string.IsNullOrEmpty(item.FbId))
                            {
                                newEnt.FbId = item.FbId;
                            }
                            newEnt.RankScore = CalculateRankScore(newEnt);
                            ctx.User.Add(newEnt);
                            ctx.SaveChanges();
                            item.UId = newEnt.UId;
                        }
                        else
                        {
                            return(new WorldScore()
                            {
                                Msg = "Try Another Name"
                            });
                        }
                    }
                    else
                    {
                        if (chkUser.Score < item.Score &&
                            chkUser.Stages < item.Stages)
                        {
                        }
                    }
                }
            }
            return(GetTopTen(item.UId));
        }