Beispiel #1
0
        /// <summary>
        /// Create a new StarterCompetition object.
        /// </summary>
        /// <param name="id">Initial value of the Id property.</param>
        /// <param name="starterId">Initial value of the StarterId property.</param>
        /// <param name="competitionId">Initial value of the CompetitionId property.</param>
        public static StarterCompetition CreateStarterCompetition(global::System.Int64 id, global::System.Int64 starterId, global::System.Int64 competitionId)
        {
            StarterCompetition starterCompetition = new StarterCompetition();

            starterCompetition.Id            = id;
            starterCompetition.StarterId     = starterId;
            starterCompetition.CompetitionId = competitionId;
            return(starterCompetition);
        }
Beispiel #2
0
        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            using (EODbEntities db = new EODbEntities())
            {
                db.Attach(_starter);

                _starter.FirstName = _firstNameTextBox.Text;
                _starter.LastName  = _lastNameTextBox.Text;
                _starter.Club      = _clubTextBox.Text;
                _starter.Pony      = _ponyTextBox.Text;
                _starter.Comment   = _commentTextBox.Text;

                _starter.Birthdate = _birthdateDatePicker.SelectedDate;

                foreach (var item in (List <CheckedListItem <Competition> >)_competitionListBox.DataContext)
                {
                    bool itemExists = _starter.StarterCompetition.Any(c => c.CompetitionId == item.Item.Id);

                    if (item.IsChecked && !itemExists)
                    {
                        // if the item is not checked in the database
                        // and the user checked it now
                        // create a new item and add it to startercompetition collection

                        StarterCompetition sc = new StarterCompetition
                        {
                            CompetitionId = item.Item.Id,
                            StarterId     = _starter.Id
                        };

                        _starter.StarterCompetition.Add(sc);
                    }
                    else if (!item.IsChecked && itemExists)
                    {
                        // if the item is checked in the database
                        // and the user unchecked it now
                        // delete the item and remove it from the startercompetition collection

                        var itemToDelete = _starter.StarterCompetition.Single(c => c.CompetitionId == item.Item.Id);
                        db.DeleteObject(itemToDelete);
                        _starter.StarterCompetition.Remove(itemToDelete);
                    }
                    else
                    {
                        // if the item state has not changed
                        // do nothing
                    }
                }

                db.SaveChanges();
            }

            this.DialogResult = true;
            this.Close();
        }
Beispiel #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the StarterCompetition EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStarterCompetition(StarterCompetition starterCompetition)
 {
     base.AddObject("StarterCompetition", starterCompetition);
 }