Example #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));
        }
Example #2
0
        public DataTransfer <WorldScore> UpdateEntry([FromBody] FirstEntry item)
        {
            DataTransfer <WorldScore> ret = new DataTransfer <WorldScore>();

            try
            {
                ret.Data = bLayer.UpdateWholeEntry(item);
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Errors    = new string[] { ex.Message.ToString() };
            }
            return(ret);
        }
Example #3
0
 private void MakeSelection()
 {
     FirstEntry.Focus();
     FirstEntry.CursorPosition  = 4;
     FirstEntry.SelectionLength = 11;
 }
Example #4
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));
        }