public DataTable ModifyChallenge()
        {
            Challenge item;

            try
            {
                item     = new Challenge(Kv.Cxt, ChallengeID);
                item.Cxt = base.Kv.Cxt;
                item.ChallengerUserID      = ChallengerUserID;
                item.ChallengeTypeID       = ChallengeTypeID;
                item.ChessTypeID           = ChessTypeID;
                item.ColorID               = ColorID;
                item.IsRated               = IsRated;
                item.WithClock             = WithClock;
                item.IsChallengerSendsGame = IsChallengerSendsGame;
                item.Description           = Description;
                item.GameTypeID            = GameTypeID;
                item.OpponentUserID        = OpponentUserID;
                item.RoomID             = RoomID;
                item.StatusID           = StatusID;
                item.TimeMin            = TimeMin;
                item.GainPerMoveMin     = GainPerMoveMin;
                item.ChallengeStatusIDE = ChallengeStatusE.Seeking;
                item.Cxt.CurrentUserID  = Kv.Cxt.CurrentUserID;

                item.Save();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Challenges.GetChallengesByRoomID(item.Cxt, RoomID, item.Cxt.CurrentUserID));
        }
Example #2
0
        public DataTable UpdateFormula()
        {
            UserFormula item;

            try
            {
                string    selectQuery;
                DataTable table;
                selectQuery = "SELECT TOP 1 * FROM UserFormula WHERE UserID = @p1";
                table       = BaseCollection.ExecuteSql(InfiChess.UserFormula, selectQuery, UserID);

                if (table != null && table.Rows.Count > 0)
                {
                    item = new UserFormula(base.Kv.Cxt, table.Rows[0]);
                }
                else
                {
                    item = new UserFormula();
                }

                item.Cxt    = base.Kv.Cxt;
                item.UserID = UserID;

                item.IsUnrated = IsUnrated;
                item.IsRated   = IsRated;
                item.IsDucate  = IsDucate;

                item.IsNoComputer       = IsNoComputer;
                item.IsNoCentaur        = IsNoCentaur;
                item.IsFastInternetOnly = IsFastInternetOnly;

                item.MinElo = MinElo;
                item.MaxElo = MaxElo;

                item.MinTime = MinTime;
                item.MaxTime = MaxTime;

                item.MinGainPerMove = MinGainPerMove;
                item.MaxGainPerMove = MaxGainPerMove;

                item.RankID            = RankID;
                item.DucatesToOverride = DucatesToOverride;
                item.IsActive          = IsActive;

                item.Cxt.CurrentUserID = base.Kv.Cxt.CurrentUserID;

                item.Save();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Challenges.GetChallengesByRoomID(item.Cxt, base.Kv.GetInt32("RoomID"), item.Cxt.CurrentUserID));
        }
        public DataTable AddChallenge()
        {
            Challenge item;

            try
            {
                string    selectQuery;
                DataTable table;
                if (OpponentUserID != 0)
                {
                    selectQuery = "SELECT TOP 1 * FROM Challenge WHERE ChallengerUserID = @p1 AND OpponentUserID = @p2 AND ChallengeStatusID = 1 AND StatusID = 1";
                    table       = BaseCollection.ExecuteSql(InfiChess.Challenge, selectQuery, ChallengerUserID, OpponentUserID);
                }
                else
                {
                    selectQuery = "SELECT TOP 1 * FROM Challenge WHERE ChallengerUserID = @p1 AND OpponentUserID IS NULL AND ChallengeStatusID = 1 AND StatusID = 1";
                    table       = BaseCollection.ExecuteSql(InfiChess.Challenge, selectQuery, ChallengerUserID, null);
                }

                if (table != null && table.Rows.Count > 0)
                {
                    item = new Challenge(base.Kv.Cxt, table.Rows[0]);
                }
                else
                {
                    item = new Challenge();
                }

                item.Cxt = base.Kv.Cxt;
                item.ChallengerUserID      = ChallengerUserID;
                item.ChallengeTypeID       = ChallengeTypeID;
                item.ChessTypeID           = ChessTypeID;
                item.ColorID               = ColorID;
                item.IsRated               = IsRated;
                item.WithClock             = WithClock;
                item.IsChallengerSendsGame = IsChallengerSendsGame;
                item.Description           = Description;
                item.GameTypeID            = GameTypeID;

                if (OpponentUserID > 0)
                {
                    item.OpponentUserID = OpponentUserID;
                }

                item.RoomID             = RoomID;
                item.StatusID           = StatusID;
                item.TimeMin            = TimeMin;
                item.GainPerMoveMin     = GainPerMoveMin;
                item.ChallengeStatusIDE = ChallengeStatusE.Seeking;
                item.Stake             = Stake;
                item.Flate             = Flate;
                item.Cxt.CurrentUserID = Kv.Cxt.CurrentUserID;

                item.Save();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Challenges.GetChallengesByRoomID(item.Cxt, RoomID, item.Cxt.CurrentUserID));
        }