Example #1
0
        private void AddWorkerButton_Click(object sender, RoutedEventArgs e)
        {
            List <Worker> wrList = new List <Worker>();

            if (workerListView.Items != null)
            {
                for (int i = 0; i < workerListView.Items.Count; i++)
                {
                    Items Value = (Items)workerListView.Items[i];
                    wrList.Add(Value.wrk);
                }
            }



            AddWorkersToConcertWindow addWorker = new AddWorkersToConcertWindow(wrList);

            this.Visibility = Visibility.Collapsed;
            addWorker.ShowDialog();
            if (addWorker.DialogResult.HasValue && addWorker.DialogResult.Value)
            {
                workerListView.Items.Add(new Items
                {
                    wrk  = addWorker.Worker,
                    mark = addWorker.Mark
                });

                ConcertEvent concert = concertRepositoty.GetByIdFromCahce(id);

                ConcertMarks concertMark = new ConcertMarks();
                concertMark.NumOfMarks     = addWorker.Mark;
                concertMark.ConcertEventID = concert.ID;
                concertMark.WorkerID       = addWorker.Worker.ID;

                concertMarksRepositoty.Insert(concertMark);
            }
            this.Visibility = Visibility.Visible;

            workerListView.Items.Refresh();
        }
Example #2
0
        public ChangeConcertWindow(int id)
        {
            this.id = id;
            InitializeComponent();
            concertRepositoty          = new ConcertEventRepository(new ApplicationContext());
            workerRepositoty           = new WorkerRepository(new ApplicationContext());
            concertMarksRepositoty     = new ConcertMarksRepository(new ApplicationContext());
            concertTypeRepositoty      = new ConcertTypeRepository(new ApplicationContext());
            concertPlaceTypeRepository = new ConcertPlaceTypeRepository(new ApplicationContext());

            ConcertEvent concert = concertRepositoty.GetByIdFromCahce(id);

            this.BeginingDate.SelectedDate      = concert.BeginningDate;
            this.EndDate.SelectedDate           = concert.EndDate;
            this.CountryTextBox.Text            = concert.Country;
            this.CitytextBox.Text               = concert.City;
            this.AddresTextBox.Text             = concert.Address;
            this.TypeComboBox.SelectedItem      = concertTypeRepositoty.FindByID(concert.ConcertTypeId).Name;
            this.TypePlaceComboBox.SelectedItem = concertPlaceTypeRepository.FindByID(concert.ConcertPlaceTypeId).Name;
            this.DescriptionTextBox.Text        = concert.Description;


            TypeComboBox.ItemsSource      = concertTypeRepositoty.getAll().Select(p => p.Name);
            TypePlaceComboBox.ItemsSource = concertPlaceTypeRepository.getAll().Select(p => p.Name);

            IEnumerable <ConcertMarks> concertMarks;

            concertMarks = concertMarksRepositoty.getAll().Where(p => p.ConcertEventID == id);

            foreach (ConcertMarks conMark in concertMarks)
            {
                workerListView.Items.Add(new Items
                {
                    wrk  = workerRepositoty.GetByIdFromCahce(conMark.WorkerID),
                    mark = conMark.NumOfMarks
                });
            }
        }