Esempio n. 1
0
        public JsonResult GetPlayerTestSummaryData(long gameid, string code)
        {
            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);

                var result = db.Database.SqlQuery <PlayerTestSummaryData>
                                 ("exec GetPlayerTestSummary " + gameid).ToList();

                List <PlayerTestSummaryReturn> reportData = new List <PlayerTestSummaryReturn>();
                foreach (PlayerTestSummaryData row in result)
                {
                    PlayerTestSummaryReturn ptsr = new PlayerTestSummaryReturn
                    {
                        Id    = row.PlayerId,
                        Name  = row.PlayerName,
                        Value = row.PercentCorrect
                    };
                    reportData.Add(ptsr);
                }

                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 GetPlayerTestSummaryData(long gameid, string code)
Esempio n. 2
0
        public List <PlayerTestSummaryReturn> GetPlayerTestSummaryData(long gameid, string code)
        {
            /*
             * 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);

            var result = db.Database.SqlQuery <PlayerTestSummaryData>
                             ("exec GetPlayerTestSummary " + gameid).ToList();

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

            foreach (PlayerTestSummaryData row in result)
            {
                PlayerTestSummaryReturn ptsr = new PlayerTestSummaryReturn
                {
                    Id    = row.PlayerId,
                    Name  = row.PlayerName,
                    Value = row.PercentCorrect
                };
                reportData.Add(ptsr);
            }

            return(reportData);
        }