Exemplo n.º 1
0
 /// <summary>
 /// Create a new MemberTeam object.
 /// </summary>
 /// <param name="memberID">Initial value of the MemberID property.</param>
 /// <param name="teamID">Initial value of the TeamID property.</param>
 /// <param name="year">Initial value of the Year property.</param>
 public static MemberTeam CreateMemberTeam(global::System.Guid memberID, global::System.Int32 teamID, global::System.Int32 year)
 {
     MemberTeam memberTeam = new MemberTeam();
     memberTeam.MemberID = memberID;
     memberTeam.TeamID = teamID;
     memberTeam.Year = year;
     return memberTeam;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the MemberTeams EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMemberTeams(MemberTeam memberTeam)
 {
     base.AddObject("MemberTeams", memberTeam);
 }
Exemplo n.º 3
0
        void OnSaveChanges()
        {
            if (SelectedTeam == 0 || SelectedMember.ToString() == string.Empty)
            {
                ShowDialog("Team and/or member are not selected");
                return;
            }

            if (string.IsNullOrEmpty(SelectedYear))
            {
                ShowDialog("The Year is not selected");
                return;
            }

            var newMemberTeam = new MemberTeam()
                                    {
                                        Year = Convert.ToInt16(SelectedYear),
                                        MemberID = SelectedMember,
                                        TeamID = SelectedTeam
                                    };

            var existingContextTeam =
                _context.MemberTeams.Where(
                    t =>
                    (t.Year == newMemberTeam.Year)
                    && (t.Member.UserID == newMemberTeam.MemberID)
                    && (t.Team.ID == newMemberTeam.TeamID)).
                    Select(te => te).FirstOrDefault();

            if (existingContextTeam != null)
            {
                return;
            }

            try
            {
                _context.MemberTeams.Add(newMemberTeam);
                _context.SubmitChanges();

            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Error {0}", ex.Message));
            }
        }