Esempio n. 1
0
        public JsonResult GetPlayerMatchDetailData(long gameId, string code, long playerid, long matchedplayerid)
        {
            try
            {
                /*
                 * the gameId and code passed must correlate or they may be something malicious going on. so we stop
                 * the response ASAP and throw an exception
                 */
                ProbeValidate.ValidateGameCodeVersusId(gameId, code);

                int filterType = 0; //get all questions match or no-match

                var result = db.Database.SqlQuery <PlayerMatchDetailData>
                                 ("exec GetPlayerMatchDetail " + gameId + "," + playerid + ","
                                 + matchedplayerid + "," + filterType + ",'order by OrderNbr asc'").ToList();


                List <PlayerMatchDetailReturn> reportData = new List <PlayerMatchDetailReturn>();
                foreach (PlayerMatchDetailData row in result)
                {
                    PlayerMatchDetailReturn pmdr = new PlayerMatchDetailReturn
                    {
                        PlayerName          = row.PlayerName,
                        MatchedPlayerId     = row.MatchedPlayerId,
                        MatchedPlayerName   = row.MatchedPlayerName,
                        QuestionId          = row.QuestionId,
                        Question            = row.Question,
                        PlayerChoice        = row.PlayerChoice,
                        MatchedPlayerChoice = row.MatchedPlayerChoice,
                        Match         = row.Match,
                        PercentChosen = row.PercentChosen
                    };

                    reportData.Add(pmdr);
                }

                return(Json(reportData));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex); //log to elmah
                ModelState.AddModelError("", ProbeConstants.MSG_UnsuccessfulOperation_STR);
                return(Json(ModelState));
            }
        }//public JsonResult GetPlayerMatchDetailData(long gameId, string code, long playerid, long matchedplayerid)
Esempio n. 2
0
        public List <PlayerMatchDetailReturn> GetPlayerMatchDetailData(long gameid, string code, long playerid, long matchedplayerid)
        {
            /*
             * the gameid and code passed must correlate or they may be something malicious going on. so we stop
             * the response ASAP and throw an exception AND WE DO NOT CATCH IT, which should be picked up by Elmah. Exception handling here
             * have to be improved big-time
             */
            ProbeValidate.ValidateGameCodeVersusId(gameid, code);

            int filterType = 0; //get all questions match or no-match

            var result = db.Database.SqlQuery <PlayerMatchDetailData>
                             ("exec GetPlayerMatchDetail " + gameid + "," + playerid + ","
                             + matchedplayerid + "," + filterType + ",'order by OrderNbr asc'").ToList();


            List <PlayerMatchDetailReturn> reportData = new List <PlayerMatchDetailReturn>();

            foreach (PlayerMatchDetailData row in result)
            {
                PlayerMatchDetailReturn pmdr = new PlayerMatchDetailReturn
                {
                    PlayerName          = row.PlayerName,
                    MatchedPlayerId     = row.MatchedPlayerId,
                    MatchedPlayerName   = row.MatchedPlayerName,
                    QuestionId          = row.QuestionId,
                    Question            = row.Question,
                    PlayerChoice        = row.PlayerChoice,
                    MatchedPlayerChoice = row.MatchedPlayerChoice,
                    Match         = row.Match,
                    PercentChosen = row.PercentChosen
                };

                reportData.Add(pmdr);
            }

            return(reportData);
        }