Наследование: INotifyPropertyChanging, INotifyPropertyChanged
Пример #1
0
        /// <summary>
        /// Creates a new DB entry for a team member.
        /// </summary>
        /// <param name="teamMember">Member to be added to the DB.</param>
        /// <param name="teamId">Team ID that the member should be added to.</param>
        /// <returns>ID of the newly added Team Member entry on success, 0 on failure.</returns>
        public static int CreateNewTeamMember(ContestTeamMember teamMember, int teamId)
        {
            try
            {
                int contestId = TeamDAO.GetContestIdFromTeamId(teamId);

                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    if (TeamDAO.UserCompetingInContest(teamMember.UserId, contestId)) { throw new Exception("User is already competing in the contest"); }

                    var data = new ActivEarthDataProvidersDataContext(connection);
                    var userData = new TeamMemberDataProvider
                    {
                        contest_id = contestId,
                        team_id = teamId,
                        user_id = teamMember.UserId,
                        score = teamMember.Score,
                        initialized = teamMember.Initialized,
                        initial_score = teamMember.InitialScore
                    };
                    data.TeamMemberDataProviders.InsertOnSubmit(userData);
                    data.SubmitChanges();
                    return userData.id;
                }
            }
            catch (Exception)
            {
                return 0;
            }
        }
Пример #2
0
 /// <summary>
 /// Creates a new DB entry for a team member.
 /// </summary>
 /// <param name="teamMember">Member to be added to the DB.</param>
 /// <param name="teamId">Team ID that the member should be added to.</param>
 /// <returns>ID of the newly added Team Member entry on success, 0 on failure.</returns>
 public static int CreateNewTeamMember(TeamMember teamMember, int teamId)
 {
     try
     {
         using (SqlConnection connection = ConnectionManager.GetConnection())
         {
             var data = new ActivEarthDataProvidersDataContext(connection);
             var userData = new TeamMemberDataProvider
             {
                 team_id = (int)teamId,
                 user_id = (int)teamMember.User.UserID,
                 initialized = teamMember.Initialized,
                 initial_score = teamMember.InitialScore
             };
             data.TeamMemberDataProviders.InsertOnSubmit(userData);
             data.SubmitChanges();
             return userData.id;
         }
     }
     catch (Exception)
     {
         return 0;
     }
 }
 partial void DeleteTeamMemberDataProvider(TeamMemberDataProvider instance);
 partial void UpdateTeamMemberDataProvider(TeamMemberDataProvider instance);
 partial void InsertTeamMemberDataProvider(TeamMemberDataProvider instance);
		private void detach_TeamMemberDataProviders(TeamMemberDataProvider entity)
		{
			this.SendPropertyChanging();
			entity.UserDataProvider = null;
		}
		private void attach_TeamMemberDataProviders(TeamMemberDataProvider entity)
		{
			this.SendPropertyChanging();
			entity.ContestDataProvider = this;
		}