예제 #1
0
        public JsonResult Add(ScoreModel score)
        {
            using (var scoreRepository = new ScoreRepository())
            {
                scoreRepository.Add(new ScoreDTO {
                    FinalScore = score.FinalScore, StudentId = score.StudentId, SubjectId = score.SubjectId
                });
            }

            return(Json("ok"));
        }
        public ActionResult Snake(int skor2)
        {
            //try
            //{
            AppUser kullanici = Session["girisyapan"] as AppUser;



            if (asRep.Any(x => x.AppUserID == kullanici.ID && x.Game == "Snake") == true)
            {
                AppUserScore varOlanKullaniciScore = asRep.Default(x => x.AppUserID == kullanici.ID && x.Game == "Snake");

                Score skor = sRep.Default(x => x.ID == varOlanKullaniciScore.ScoreID);
                if (skor2 > skor.ScoreValue)
                {
                    skor.ScoreValue = skor2;
                    sRep.Update(skor);
                }
                else
                {
                    ViewBag.gec = "Daha önceki skorunuzu geçemediniz. Oyun kaydedilmedi.";
                }
            }
            else
            {
                AppUserScore kullaniciScore = new AppUserScore();
                kullaniciScore.AppUserID = kullanici.ID;

                Score score = new Score();
                score.ScoreValue = skor2;
                sRep.Add(score);

                kullaniciScore.ScoreID = score.ID;
                kullaniciScore.Game    = "Snake";



                asRep.Add(kullaniciScore);
            }



            return(Json(new { result = 1, puan = skor2 }));
            //}
            //catch (Exception)
            //{

            //    return Json(new { result = 0 });
            //}
        }
예제 #3
0
        private void AddScore(int gameId, string userId, int drinks)
        {
            Score score = scoreRepo.getByGameAndUser(gameId, userId);

            if (score == null)
            {
                scoreRepo.Add(new Score()
                {
                    gameId = gameId,
                    userId = userId,
                    score1 = drinks
                });
            }
            else
            {
                score.score1 += drinks;
                scoreRepo.Update(score);
            }
            scoreRepo.Save();
        }
예제 #4
0
 public void SelectCourse(int id, int code)
 {
     scoreRepository.Add(id, code);
 }