コード例 #1
0
ファイル: HomeController.cs プロジェクト: fletchr0cks/leader1
        public JsonResult newScore(int GID, int YID, int HID, int UserID, int score, int Pin, int LD)
        {
            var dataContext = new lb3dataDataContext();

            var otherplayers = from users in dataContext.UserGroups
                               where users.GID == GID
                               where users.UserID != UserID
                               select new
                               {
                                   UserID = users.UserID
                               };

            var HoleData = from h in dataContext.Holes
                           where h.HoleID == HID
                           select h;

            var HoleNum = HoleData.First().HoleNum;

            var CID = HoleData.First().CourseID;

            var winner = from users in dataContext.Users
                               where users.UserID == UserID
                               select users;

            var ck_score = from s in dataContext.Scores
                     where s.YearID == YID
                     where s.UserID == UserID
                     where s.HoleID == HID
                     select s;

            var ck_pin = from s in dataContext.Scores
                           where s.YearID == YID
                           where s.PinUserID == UserID
                           where s.HoleID == HID
                           select s;

            var ck_LD = from s in dataContext.Scores
                         where s.YearID == YID
                         where s.DriveUserID == UserID
                         where s.HoleID == HID
                         select s;
            var type = "";
            if (ck_score.Count() == 1 || ck_pin.Count() == 1 || ck_LD.Count() == 1)
            {
                //update stuff
                type = "Updated";
                if (score > 0)
                {
                    dataRepository.UpdateScore(ck_score.First().ScID, score);
                }
                else
                {
                    if (Pin == 1)
                    {
                        dataRepository.ResetPin(YID, HID);
                        dataRepository.UpdatePin(ck_score.First().ScID, UserID);
                        dataRepository.CheckScorePLD(HID, UserID, "Pin");
                    }

                    if (LD == 1)
                    {
                        dataRepository.ResetLD(YID, HID);
                        dataRepository.UpdateLD(ck_score.First().ScID, UserID);
                        dataRepository.CheckScorePLD(HID, UserID, "LD");
                    }

                }
            }
            else
            {
                //insert stuff
                type = "Saved";
                if (Pin == 1)
                {
                    dataRepository.ResetPin(YID, HID);
                    Score sc = new Score();
                    sc.PinUserID = UserID;
                    sc.UserID = UserID;
                    sc.YearID = YID;
                    sc.HoleID = HID;
                    sc.GID = GID;
                    dataRepository.Add(sc);
                    dataRepository.Save();
                    dataRepository.CheckScore(0, GID, YID, HID, UserID);
                    dataRepository.CheckScorePLD(HID, UserID, "Pin");
                }
                else if (LD == 1)
                {
                    dataRepository.ResetLD(YID, HID);
                    Score sc = new Score();
                    sc.DriveUserID = UserID;
                    sc.UserID = UserID;
                    sc.YearID = YID;
                    sc.HoleID = HID;
                    sc.GID = GID;
                    dataRepository.Add(sc);
                    dataRepository.Save();
                    dataRepository.CheckScore(0, GID, YID, HID, UserID);
                    dataRepository.CheckScorePLD(HID, UserID, "LD");
                }
                else
                {
                    Score sc = new Score();
                    sc.HoleID = HID;
                    sc.YearID = YID;
                    sc.GID = GID;
                    sc.UserID = UserID;
                    sc.Score1 = score;

                    dataRepository.Add(sc);
                    dataRepository.Save();
                    dataRepository.CheckScore(0, GID, YID, HID, UserID);

                }
            }
            if (type == "Saved")
            {
                return Json(new { members = otherplayers, winner = winner.First().Nickname, type = "Saved to server", HoleNum = HoleNum, CID = CID, YID = YID });
            }
            else
            {
                return Json(new { members = otherplayers, winner = winner.First().Nickname, type = "Updated to server", HoleNum = HoleNum, CID = CID, YID = YID });
            }
        }
コード例 #2
0
ファイル: DataRepository.cs プロジェクト: fletchr0cks/lb3
 public void Add(Score sc)
 {
     db.Scores.InsertOnSubmit(sc);
 }
コード例 #3
0
 partial void DeleteScore(Score instance);
コード例 #4
0
 partial void UpdateScore(Score instance);
コード例 #5
0
 partial void InsertScore(Score instance);
コード例 #6
0
		private void detach_Scores(Score entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
コード例 #7
0
		private void attach_Scores(Score entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}