示例#1
0
        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);

            


        }
示例#2
0
        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);
            
        }
示例#3
0
        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);
        }