private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            ConcertEvent concert = new ConcertEvent();

            concert.BeginningDate      = this.BeginingDate.SelectedDate;
            concert.EndDate            = this.EndDate.SelectedDate;
            concert.Country            = this.CountryTextBox.Text;
            concert.City               = this.CitytextBox.Text;
            concert.Address            = this.AddresTextBox.Text;
            concert.ConcertTypeId      = concertTypeRepositoty.Get(p => p.Name == this.TypeComboBox.Text).First().ID;
            concert.ConcertPlaceTypeId = concertPlaceTypeRepository.Get(p => p.Name == this.TypePlaceComboBox.Text).First().ID;
            concert.Description        = this.DescriptionTextBox.Text;


            concertRepositoty.Insert(concert);

            if (workerListView.Items != null)
            {
                concert.ConcertMarks = null;
                //ICollection<ConcertMarks> concertMarks = new System.Collections.ObjectModel.Collection<ConcertMarks>();
                for (int i = 0; i < workerListView.Items.Count; i++)
                {
                    Items Value = (Items)workerListView.Items[i];

                    ConcertMarks concertMark = new ConcertMarks();
                    concertMark.NumOfMarks     = Value.mark;
                    concertMark.ConcertEventID = concert.ID;
                    concertMark.WorkerID       = Value.wrk.ID;


                    concertMarksRepositoty.Insert(concertMark);
                }
                concertRepositoty.Update(concert);
            }

            concertRepositoty.UpdateCache(concert, concert.ID);


            MessageBox.Show("добавлен");
            Close_Click(sender, e);
            //this.btnReload_Click(sender, e);
        }
Exemple #2
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            ConcertEvent concert = concertRepositoty.FindByID(id);

            concert.BeginningDate      = this.BeginingDate.SelectedDate;
            concert.EndDate            = this.EndDate.SelectedDate;
            concert.Country            = this.CountryTextBox.Text;
            concert.City               = this.CitytextBox.Text;
            concert.Address            = this.AddresTextBox.Text;
            concert.ConcertTypeId      = concertTypeRepositoty.Get(p => p.Name == this.TypeComboBox.Text).First().ID;
            concert.ConcertPlaceTypeId = concertPlaceTypeRepository.Get(p => p.Name == this.TypePlaceComboBox.Text).First().ID;
            concert.Description        = this.DescriptionTextBox.Text;


            concertRepositoty.Modified(concert);
            concertRepositoty.Update(concert);
            concertRepositoty.UpdateCache(concert, concert.ID);

            MessageBox.Show("changed");
            Close_Click(sender, e);
        }