Пример #1
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);
            
        }
Пример #2
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);
        }