Exemplo n.º 1
0
        public void AddNewUrlaub()
        {
            Urlaub neu = new Urlaub();

            neu.Beschreibung = NeuerUrlaub.Beschreibung;
            neu.Bild         = NeuerUrlaub.Bild;
            neu.Urlaubsart   = NeuerUrlaub.Urlaubsart;

            int hoechsteId = ObservableUrlaubsCollection.Max(u => u.UrlaubId);

            neu.UrlaubId = ++hoechsteId;
            ObservableUrlaubsCollection.Add(neu);
            //Zusätzlich auch in DB speichern
            urlaubsContext.Urlaub.Add(neu);
            urlaubsContext.SaveChanges();

            int x = (1 > 2) ? 5 : 7;

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("AnzahlUrlaubGesamt"));

                if (NeuerUrlaub.Urlaubsart == "Relax")
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("AnzahlUrlaubRelax"));
                }

//                (NeuerUrlaub.Urlaubsart == "Relax")? PropertyChanged(this, new PropertyChangedEventArgs("AnzahlUrlaubRelax"));

                if (NeuerUrlaub.Urlaubsart == "Action")
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("AnzahlUrlaubAction"));
                }
            }
        }
Exemplo n.º 2
0
        public MainWindowViewModel()
        {
            ObservableUrlaubsCollection = new ObservableCollection <Urlaub>();

            // InitFirstLoad();
            //Server Exlorer - Add DataConnection - Databasefile -- Users-Directory - UrlaubWPF.Model.UrlaubsContext.mdf
            InitLoad();

            AusgewaehlterUrlaub = ObservableUrlaubsCollection[1];

            Urlaubsarten = new ObservableCollection <string>();
            Urlaubsarten.Add("Relax");
            Urlaubsarten.Add("Action");

            NeuerUrlaub = new Urlaub();
        }