Example #1
0
        public JsonResult GetGamePlayerMatchMinMaxData(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 <GamePlayerMatchMinMaxData>
                                 ("exec GetGamePlayerMatchMinMax " + gameid).ToList();

                List <GamePlayerMatchMinMaxReturn> reportData = new List <GamePlayerMatchMinMaxReturn>();
                foreach (GamePlayerMatchMinMaxData row in result)
                {
                    GamePlayerMatchMinMaxReturn gpmmmr = new GamePlayerMatchMinMaxReturn
                    {
                        PlayerId                 = row.PlayerId,
                        PlayerName               = row.PlayerName,
                        MaleMaxNbrOfMatched      = row.MaleMaxNbrOfMatched,
                        MaleMaxMatchedPlayerId   = row.MaleMaxMatchedPlayerId,
                        MaleMaxPlayerName        = row.MaleMaxPlayerName,
                        MaleMinNbrOfMatched      = row.MaleMinNbrOfMatched,
                        MaleMinMatchedPlayerId   = row.MaleMinMatchedPlayerId,
                        MaleMinPlayerName        = row.MaleMinPlayerName,
                        FemaleMaxNbrOfMatched    = row.FemaleMaxNbrOfMatched,
                        FemaleMaxMatchedPlayerId = row.FemaleMaxMatchedPlayerId,
                        FemaleMaxPlayerName      = row.FemaleMaxPlayerName,
                        FemaleMinNbrOfMatched    = row.FemaleMinNbrOfMatched,
                        FemaleMinMatchedPlayerId = row.FemaleMinMatchedPlayerId,
                        FemaleMinPlayerName      = row.FemaleMinPlayerName,
                    };
                    reportData.Add(gpmmmr);
                }

                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 GetGamePlayerMatchMinMaxData(long gameid, string code)
Example #2
0
        public List <GamePlayerMatchMinMaxReturn> GetGamePlayerMatchMinMaxData(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 <GamePlayerMatchMinMaxData>
                             ("exec GetGamePlayerMatchMinMax " + gameid).ToList();

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

            foreach (GamePlayerMatchMinMaxData row in result)
            {
                GamePlayerMatchMinMaxReturn gpmmmr = new GamePlayerMatchMinMaxReturn
                {
                    PlayerId                 = row.PlayerId,
                    PlayerName               = row.PlayerName,
                    MaleMaxNbrOfMatched      = row.MaleMaxNbrOfMatched,
                    MaleMaxMatchedPlayerId   = row.MaleMaxMatchedPlayerId,
                    MaleMaxPlayerName        = row.MaleMaxPlayerName,
                    MaleMinNbrOfMatched      = row.MaleMinNbrOfMatched,
                    MaleMinMatchedPlayerId   = row.MaleMinMatchedPlayerId,
                    MaleMinPlayerName        = row.MaleMinPlayerName,
                    FemaleMaxNbrOfMatched    = row.FemaleMaxNbrOfMatched,
                    FemaleMaxMatchedPlayerId = row.FemaleMaxMatchedPlayerId,
                    FemaleMaxPlayerName      = row.FemaleMaxPlayerName,
                    FemaleMinNbrOfMatched    = row.FemaleMinNbrOfMatched,
                    FemaleMinMatchedPlayerId = row.FemaleMinMatchedPlayerId,
                    FemaleMinPlayerName      = row.FemaleMinPlayerName,
                };
                reportData.Add(gpmmmr);
            }

            return(reportData);
        }