public List <PlayerTestDetailReturn> GetPlayerTestDetailData(long gameid, string code, long playerid) { /* * 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 <PlayerTestDetailData> ("exec GetPlayerTestDetail " + gameid + "," + playerid).ToList(); List <PlayerTestDetailReturn> reportData = new List <PlayerTestDetailReturn>(); foreach (PlayerTestDetailData row in result) { PlayerTestDetailReturn ptdr = new PlayerTestDetailReturn { PlayerName = row.PlayerName, QuestionId = row.QuestionId, Question = row.Question, OrderNbr = row.OrderNbr, SelectedChoices = row.SelectedChoices, CorrectChoices = row.CorrectChoices, QuestionCorrect = row.QuestionCorrect, PercentCorrect = row.PercentCorrect }; reportData.Add(ptdr); } return(reportData); }
public JsonResult GetPlayerTestDetailData(long gameId, string code, long playerid) { 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 <PlayerTestDetailData> ("exec GetPlayerTestDetail " + gameId + "," + playerid).ToList(); List <PlayerTestDetailReturn> reportData = new List <PlayerTestDetailReturn>(); foreach (PlayerTestDetailData row in result) { PlayerTestDetailReturn ptdr = new PlayerTestDetailReturn { PlayerName = row.PlayerName, QuestionId = row.QuestionId, Question = row.Question, OrderNbr = row.OrderNbr, SelectedChoices = row.SelectedChoices, CorrectChoices = row.CorrectChoices, QuestionCorrect = row.QuestionCorrect, PercentCorrect = row.PercentCorrect }; reportData.Add(ptdr); } 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 GetPlayerTestDetailData(long gameId, string code, long playerid)