コード例 #1
0
		private void detach_GroupSign(GroupSign entity)
		{
			this.SendPropertyChanging();
			entity.Profil = null;
		}
コード例 #2
0
		private void attach_GroupSign(GroupSign entity)
		{
			this.SendPropertyChanging();
			entity.Profil = this;
		}
コード例 #3
0
 partial void DeleteGroupSign(GroupSign instance);
コード例 #4
0
 partial void UpdateGroupSign(GroupSign instance);
コード例 #5
0
 partial void InsertGroupSign(GroupSign instance);
コード例 #6
0
        public bool CreateOrUpdateGroupSign(int eventId, int profilId, int score)
        {
            using (MasterDBDataContext db = new MasterDBDataContext())
            {
                Event eventGame = db.Event.SingleOrDefault(e => e.idEvent == eventId);
                Profil profil = db.Profil.SingleOrDefault(p => p.idProfil == profilId);

                if (eventGame != null && profil != null)
                {
                    GroupSign groupSign = null;
                    groupSign = db.GroupSign.SingleOrDefault(gs => gs.idEvent == eventId && gs.idProfil == profilId);

                    if (groupSign == null)
                    {
                        groupSign = new GroupSign()
                        {
                            idEvent = eventId,
                            idProfil = profil.idProfil,
                            Score = score
                        };

                        db.GroupSign.InsertOnSubmit(groupSign);
                    }
                    else
                    {
                        if (groupSign.Score < score)
                        {
                            groupSign.Score = score;
                        }
                    }

                    try
                    {
                        db.SubmitChanges();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Create Group Sign " + ex.Message);
                        return false;
                    }
                }
            }
            return true;
        }