Beispiel #1
0
        private void Update_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (PhotographerListBox.SelectedItem != null && _photographerListViewModel.ValidBirthday && _photographerListViewModel.ValidFirstName && _photographerListViewModel.ValidSurname)
            {
                PhotographerViewModel vm = (PhotographerViewModel)PhotographerListBox.SelectedItem;

                if (BirthdayBox.SelectedDate <= DateTime.Today)
                {
                    vm.Birthday = BirthdayBox.SelectedDate;
                }
                if (SurnameBox.Text != "Surname" && SurnameBox.Text.Replace(" ", "").Length > 0)
                {
                    vm.Surname = SurnameBox.Text;
                }
                if (FirstnameBox.Text != "First Name" && FirstnameBox.Text.Replace(" ", "").Length > 0)
                {
                    vm.Name = FirstnameBox.Text;
                }
                if (_photographerListViewModel.ModifiedNotes)
                {
                    vm.Notes = NotesBox.Text;
                }

                BusinessLayer.UpdatePhotographer(vm);
                _photographerListViewModel = new PhotographerListViewModel(BusinessLayer.GetAllPhotographers());

                _photographerListViewModel.ValidBirthday  = true;
                _photographerListViewModel.ValidFirstName = true;
                _photographerListViewModel.ValidSurname   = true;

                PhotographerListBox.ItemsSource  = _photographerListViewModel.PhotographerViewModels;
                PhotographerListBox.SelectedItem = _photographerListViewModel.PhotographerViewModels[0];
            }
        }
Beispiel #2
0
        private void Create_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //This seems botchy, but currently you can bypass the "live" validity check with backspace, as this doesn't register as a keystroke, so we have to check it again for creation
            _photographerListViewModel.ValidFirstName = (SurnameBox.Text != "Surname" && SurnameBox.Text.Replace(" ", "").Length > 0);
            _photographerListViewModel.ValidSurname   = (FirstnameBox.Text != "First Name" && FirstnameBox.Text.Replace(" ", "").Length > 0);

            if (_photographerListViewModel.ValidBirthday && _photographerListViewModel.ValidFirstName && _photographerListViewModel.ValidSurname)
            {
                PhotographerViewModel vm = new PhotographerViewModel();

                if (BirthdayBox.SelectedDate <= DateTime.Today)
                {
                    vm.Birthday = BirthdayBox.SelectedDate;
                }

                vm.Surname = SurnameBox.Text;
                vm.Name    = FirstnameBox.Text;

                if (_photographerListViewModel.ModifiedNotes)
                {
                    vm.Notes = NotesBox.Text;
                }

                BusinessLayer.CreatePhotographer(vm);
                _photographerListViewModel       = new PhotographerListViewModel(BusinessLayer.GetAllPhotographers());
                PhotographerListBox.ItemsSource  = _photographerListViewModel.PhotographerViewModels;
                PhotographerListBox.SelectedItem = _photographerListViewModel.PhotographerViewModels[0];
            }
        }
Beispiel #3
0
 public void SetPhotographers(PhotographerListViewModel p)
 {
     foreach (IPictureViewModel picture in List)
     {
         if (picture.Photographer != null)
         {
             ((PictureViewModel)picture).Photographer = p.GetPhotographer(picture.Photographer.ID);
         }
     }
 }
Beispiel #4
0
        ///
        /// Initialization for the EditWindow
        ///
        public EditWindow()
        {
            InitializeComponent();
            _photographerListViewModel = new PhotographerListViewModel(BusinessLayer.GetAllPhotographers());

            _photographerListViewModel.ValidBirthday  = true;
            _photographerListViewModel.ValidFirstName = FirstnameBox.Text.Length <= 100;
            _photographerListViewModel.ValidSurname   = SurnameBox.Text.Length <= 50;

            FirstnameBox.Background = _photographerListViewModel.ValidFirstName ? _green : _red;
            SurnameBox.Background   = _photographerListViewModel.ValidSurname ? _green : _red;
            BirthdayBox.Background  = _photographerListViewModel.ValidBirthday ? _green : _red;
            NotesBox.Background     = _green;

            PhotographerListBox.ItemsSource = _photographerListViewModel.PhotographerViewModels;
        }
Beispiel #5
0
 public MainWindowViewModel(UpdateSources UpdatePicture, UpdateSources UpdatePhotographer, UpdateSources UpdateCamera)
 {
     _UpdatePicture      = UpdatePicture;
     _UpdatePhotographer = UpdatePhotographer;
     _UpdateCamera       = UpdateCamera;
     bl.Error           += (message) => System.Windows.MessageBox.Show(message);
     bl.Sync();
     _List       = new PictureListViewModel(bl.GetPictures(null, null, null, null));
     _CameraList = new CameraListViewModel(bl.GetCameras());
     ((PictureListViewModel)List).SetCameras(CameraList);
     _PhotographerList = new PhotographerListViewModel(bl.GetPhotographers());
     ((PictureListViewModel)List).SetPhotographers(PhotographerList);
     _Search = new SearchViewModel();
     //nicht neu instanzieren
     _Search.SearchActivated += (s, e) => List = new PictureListViewModel(bl.GetPictures(e.Searchtext, null, null, null));
 }