Exemplo n.º 1
0
        public Kwekerij(string bedrijfsnaam, string straat, string postcode, string plaats, string telefoonnummer, string faxnummer, string mobiel, string email, string iban, string btwNummer, string kvkNummer)
        {
            // Initialize Properties
            Bedrijfsnaam   = bedrijfsnaam;
            Straat         = straat;
            Postcode       = postcode;
            Plaats         = plaats;
            Telefoonnummer = telefoonnummer;
            Faxnummer      = faxnummer;
            Mobiel         = mobiel;
            Email          = email;
            Iban           = iban;
            BtwNummer      = btwNummer;
            KvkNummer      = kvkNummer;

            // Initialize Repositories with Contexts
            klantRepo      = new KlantRepository(new KlantSQLiteContext());
            bestellingRepo = new BestellingRepository(new BestellingSQLiteContext());
            plantRepo      = new PlantRepository(new PlantSQLiteContext());

            // Initialize Lists
            Klanten      = new ObservableCollection <Klant>(klantRepo.GetAll());
            Planten      = new ObservableCollection <Plant>(plantRepo.GetAll());
            Bestellingen = new ObservableCollection <Bestelling>(bestellingRepo.GetAll());

            // Bind
            foreach (Bestelling bestelling in Bestellingen)
            {
                bestelling.Klant = Klanten.Single(k => k.Id == bestelling.Klant.Id);
                foreach (Bestelregel bestelregel in bestelling.Bestelregels)
                {
                    bestelregel.Plant = Planten.Single(p => p.Id == bestelregel.Plant.Id);
                }
            }

            // Initialialize Change Events in Observable Lists
            Klanten.CollectionChanged += ObservableListCollection_CollectionChanged;
            foreach (Klant klant in Klanten)
            {
                klant.PropertyChanged += ItemPropertyChanged;
            }

            Planten.CollectionChanged += ObservableListCollection_CollectionChanged;
            foreach (Plant plant in Planten)
            {
                plant.PropertyChanged += ItemPropertyChanged;
            }

            Bestellingen.CollectionChanged += ObservableListCollection_CollectionChanged;
            foreach (Bestelling bestelling in Bestellingen)
            {
                bestelling.PropertyChanged += ItemPropertyChanged;
                bestelling.Bestelregels.CollectionChanged += ObservableListCollection_CollectionChanged;
                foreach (Bestelregel bestelregel in bestelling.Bestelregels)
                {
                    bestelregel.Leveringen.CollectionChanged += ObservableListCollection_CollectionChanged;
                }
            }
        }
Exemplo n.º 2
0
        public void Get_All_Klanten_Test()
        {
            klantList = klantRepository.GetAll();

            Assert.AreEqual(3, klantList.Count);
        }