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)
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); }