コード例 #1
0
ファイル: ProfileController.cs プロジェクト: rehnz/dev
        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));
        }
コード例 #2
0
ファイル: ProfileController.cs プロジェクト: rehnz/dev
        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));
        }