public JsonResult DeleteScore(ScoresModel scoreToDelete) { SqlTool sqltool = new SqlTool(); int scoreid = scoreToDelete.id; string deleteScoreQuery = @"Delete from Scores where id = " + scoreid; sqltool.runQuery(deleteScoreQuery); return Json(null, JsonRequestBehavior.AllowGet); }
public JsonResult AddScore(ScoresModel newScore) { SqlTool sqltool = new SqlTool(); HandicapCalculator handicap = new HandicapCalculator(); //populate Course Model decimal adjustedScore = handicap.AdjustScore(newScore.score, newScore.courseid); string newScoreInsert = String.Format(@"INSERT INTO Scores(userid,courseid,score,dateplayed,adjustedscore) SELECT {0},{1},{2},'{3}',{4}", Session["id"], newScore.courseid, newScore.score, newScore.dateplayed.ToShortDateString(), adjustedScore); sqltool.runQuery(newScoreInsert); return Json(newScore, JsonRequestBehavior.AllowGet); }
public JsonResult UpdateScore(ScoresModel scoreToUpdate) { SqlTool sql = new SqlTool(); HandicapCalculator handicap = new HandicapCalculator(); decimal adjustedScore = handicap.AdjustScore(scoreToUpdate.score, scoreToUpdate.courseid); string updateScoreQuery = @"Update scores set Score = " + scoreToUpdate.score + ",adjustedscore = " + adjustedScore + " where id = " + scoreToUpdate.id; sql.runQuery(updateScoreQuery); return Json(null, JsonRequestBehavior.AllowGet); }