Example #1
0
        public void Fill(KontekstDanych kontekstDanych)
        {
            XDocument xDocument = XDocument.Load(_XMLpath);
            int       i         = 1;

            foreach (XElement element in xDocument.Descendants("Book"))
            {
                int bookID;
                int.TryParse(element.Element("BookID").Value, out bookID);
                string title = element.Element("Name").Value;
                Book   book  = new Book(bookID, title);

                kontekstDanych.BooksDictionary.Add(i, book);
                i++;
            }

            foreach (XElement element in xDocument.Descendants("Reader"))
            {
                string name    = element.Element("Name").Value;
                string surname = element.Element("Surname").Value;
                int    personalID;
                int.TryParse(element.Element("PersonalID").Value, out personalID);
                Reader reader = new Reader(name, surname, personalID);

                kontekstDanych.clientList.Add(reader);
            }
        }
Example #2
0
        public void Fill(KontekstDanych kontekstDanych)
        {
            kontekstDanych.clientList.Add(new Reader("Jan", "Kowalski", 1));
            kontekstDanych.clientList.Add(new Reader("Tomasz", "Kowalski", 2));
            kontekstDanych.clientList.Add(new Reader("Janusz", "Kowalski", 3));

            kontekstDanych.BooksDictionary.Add(1, new Book(1, "Ksiega Dzungli"));
            kontekstDanych.BooksDictionary.Add(2, new Book(2, "Pasja C++"));
            kontekstDanych.BooksDictionary.Add(3, new Book(3, "Apokalipsa"));

            kontekstDanych.statesList.Add(new State(kontekstDanych.BooksDictionary[1], 10));
            kontekstDanych.statesList.Add(new State(kontekstDanych.BooksDictionary[2], 1));
            kontekstDanych.statesList.Add(new State(kontekstDanych.BooksDictionary[3], 110));

            kontekstDanych.borrowingsCollection.Add(new Borrowing(kontekstDanych.clientList[1], new DateTime(2018, 3, 4), kontekstDanych.statesList[0]));
            kontekstDanych.borrowingsCollection.Add(new Borrowing(kontekstDanych.clientList[2], new DateTime(2018, 3, 5), kontekstDanych.statesList[1]));
            kontekstDanych.borrowingsCollection.Add(new Borrowing(kontekstDanych.clientList[0], new DateTime(2018, 3, 6), kontekstDanych.statesList[2]));
        }