static void Main()
    {
        Authors authors = new Authors();

        authors.Add(new Person("James"));
        authors.Add(new Person("Roger"));
        authors.Add(new Person("Ben"));
        authors.Add(new Person("Richard"));
        authors.Add(new Person("Teun"));

        for (int i = 0; i < authors.Count; i++)
        {
            Console.WriteLine(authors[i].Name);
        }
    }
        public void Open(string filename)
        {
            var doc = new XmlDocument();

            doc.Load(filename);

            var xmlHelper = new XmlHelper(doc);

            XmlNode root = doc.DocumentElement;

            Version = xmlHelper.GetValidChild(root, "version").InnerText;

            Authors.Clear();
            List <XmlNode> authors = xmlHelper.GetChildren(root, "author");

            foreach (XmlNode node in authors)
            {
                var author = new Pair <string, string>(node.Attributes["name"].InnerText, node.Attributes["email"].InnerText);
                Authors.Add(author);
            }

            CreatedDate = xmlHelper.GetValidChild(root, "created_date").InnerText;

            DataDependancy = xmlHelper.GetValidChild(root, "data_dependency").InnerText;

            QuantLevel = xmlHelper.GetValidChild(root, "quantLevel").InnerText;

            XmlNode profile = xmlHelper.GetValidChild(root, "PeptideProfile");

            this.nextProtein = xmlHelper.GetFirstChild(root, "Protein");
        }
Beispiel #3
0
        public CreateBlogModel()
        {
            AuthorModel a = new AuthorModel()
            {
                Name  = "Richard",
                Last  = "Brown",
                Email = "*****@*****.**"
            };
            AuthorModel b = new AuthorModel()
            {
                Name  = "Polly",
                Last  = "Town",
                Email = "*****@*****.**"
            };
            AuthorModel c = new AuthorModel()
            {
                Name  = "Jimmy",
                Last  = "John",
                Email = "*****@*****.**"
            };

            Authors.Add(a);
            Authors.Add(b);
            Authors.Add(c);
        }
Beispiel #4
0
 // обновить данные автора из скачанного с гугла
 public static void UpdateAuthorContent(Author author)
 {
     foreach (Author _author in Authors)
     {
         if (author.Id == _author.Id)
         {
             //_author.Cached = author.Cached;
             //_author.Category = author.Category;
             //_author.Comment = author.Comment;
             //_author.IsIgnored = author.IsIgnored;
             //_author.Name = author.Name;
             //_author.Texts = new BindingList<AuthorText>();
             //foreach (AuthorText authorText in author.Texts)
             //    _author.Texts.Add(authorText);
             //_author.IsNew = author.IsNew;
             //_author.timeStamp = GoogleTime;
             //_author.UpdateDate = author.UpdateDate;
             //_author.Changed = true;// говорим, что данные изменились (для хаписи в БД)
             //_author.ChangedGoogle = false;// говорим, что синхронизировать с гуглом не надо
             Authors.Remove(_author);
             Authors.Add(author);
             break;
         }
     }
 }
Beispiel #5
0
        public void SeedData()
        {
            Book book1 = new Models.Book {
                Title = "Wolf Road", DateAdded = DateTime.Now, Price = 20, Key = "Wolf Road"
            };

            //var fiction = Categories.Add(new Category { Name = "Fiction" }).Entity;
            //Error: Unable to create or track an entity of type 'Category' because it has a null primary or alternate key value.
            var fiction = Categories.Add(new Category {
                Name = "Fiction", Key = "Fiction"
            }).Entity;
            Category cat2 = new Category {
                Name = "Children", Key = "Children"
            };
            Category cat3 = new Category {
                Name = "Cooking", Key = "Cooking"
            };

            Categories.AddRange(cat2, cat3);
            book1.Category = fiction;

            var author1 = Authors.Add(new Models.Author {
                Name = "Beth Lewis", Key = "Beth Lewis"
            }).Entity;

            Authors.Add(new Models.Author {
                Name = "Unknown", Key = "Unknown"
            });
            book1.Author = author1;

            Books.Add(book1);

            SaveChanges();
        }
        public void AddNewAuthor(ActionExecutionContext context, string authorName)
        {
            if ((context.EventArgs as KeyEventArgs).Key == Key.Return && !String.IsNullOrWhiteSpace(authorName))
            {
                (context.EventArgs as KeyEventArgs).Handled = true;

                Author author = Authors.FirstOrDefault(p => p.Name.ToLower() == authorName.ToLower());
                if (author != null)
                {
                    SelectedAuthor = author;
                    return;
                }

                if (MessageBox.Show(String.Format(App.GetString("AreYouSureAddAuthor"), authorName), App.GetString("NewAuthor"),
                                    MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes)
                {
                    using (var dbService = _dbServiceManager.GetService())
                    {
                        Author newAuthor = new Author()
                        {
                            Name = authorName
                        };
                        newAuthor.Id = dbService.Authors.Add(newAuthor);

                        Authors.Add(newAuthor);
                        SelectedAuthor = newAuthor;
                    }
                }
                else
                {
                    SelectedAuthor = null;
                }
            }
        }
Beispiel #7
0
        //----< constructor generates "getting started" list of courses >----

        private AuthorList()
        {
            var user = new Author
            {
                Id        = 1,
                UserName  = "******",
                FirstName = "Jane",
                LastName  = "Doe",
                Email     = "*****@*****.**",
                BirthDate = "08/02/1988"
            };

            Authors.Add(user);
            user = new Author
            {
                Id        = 2,
                UserName  = "******",
                FirstName = "John",
                LastName  = "Doe",
                Email     = "*****@*****.**",
                BirthDate = "30/08/1979"
            };
            Authors.Add(user);
            user = new Author
            {
                Id        = 3,
                UserName  = "******",
                FirstName = "Lara",
                LastName  = "Croft",
                Email     = "*****@*****.**",
                BirthDate = "25/10/1996"
            };
            Authors.Add(user);
        }
        public Book AddAuthor(Author author)
        {
            ValidateAuthor(author);
            Authors.Add(author);

            return(this);
        }
        async Task ExecuteLoadAuthorsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Authors.Clear();
                var authors = await dataStore.GetAuthors();

                foreach (var author in authors)
                {
                    Authors.Add(author);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #10
0
        /// <summary>
        /// Method <c>loadData</c> performs the reading of
        /// the csv file containing the library extract data.
        /// It populates all data collection contained within
        /// this Library.
        /// It is called from the Library constructor, but
        /// can also be called from a Public method Load()
        /// </summary>
        private async void loadData()
        {
            //  Locate the csv file.
            var dataFile = await Helpers.DataFileHelper.GetDataFile();

            if (dataFile != null)
            {
                //  Set up the streamreader to access the file, Read only mode
                using (StreamReader reader = new StreamReader(await dataFile.OpenStreamForReadAsync()))
                {
                    while (!reader.EndOfStream)
                    {
                        string data = reader.ReadLine();
                        //  split the data into a Book record and add to the Books collection.
                        var book = Helpers.DeserialiseData.ToBook(data, _libraryBookFactory);
                        Books.Add(book);
                        //  Add to other model classes
                        Authors.Add(book.Author);
                        Titles.Add(book.Title);
                        Isbns.Add(book.ISBN);
                        //  Split the keywords and add them if they don't exist.
                        foreach (string kw in book.KeyWords)
                        {
                            Keywords.Add(kw);
                        }
                        Keywords.Sort();
                    }
                }
            }
        }
Beispiel #11
0
 public ArtifactData(MainObject main)
 {
     LrsId               = main.MainId.Value;
     OwnerEmployeeId     = main.OwnerEmployeeId;
     OwnerName           = main.OwnerName;
     OwnerEmail          = main.OwnerEmail;
     ReviewStatus        = "Approved";//main.ReviewStatus;
     ReviewProgress      = (int)main.ReviewPercent;
     DocumentType        = main.DocumentType;
     Title               = main.Title;
     StiNumber           = main.StiNumber;
     Revision            = main.Revision;
     CreateDate          = main.CreateDate;
     ModifiedDate        = main.ActivityDate;
     ApprovedDate        = main.ApprovalDate;
     Abstract            = main.Abstract;
     ConferenceName      = main.ConferenceName;
     ConferenceSponsor   = main.ConferenceSponsor;
     ConferenceLocation  = main.ConferenceLocation;
     ConferenceBeginDate = main.ConferenceBeginDate;
     ConferenceEndDate   = main.ConferenceEndDate;
     JournalName         = main.JournalName;
     RelatedSti          = main.RelatedSti;
     main.Contacts.ForEach(n => Contacts.Add(new ContactData(n)));
     main.Authors.ForEach(n => Authors.Add(new AuthorData(n)));
     main.Funding.ForEach(n => Fundings.Add(new FundingData(n)));
     main.Reviewers.ForEach(n => Reviewers.Add(new ReviewerData(n)));
     main.SubjectCategories.ForEach(n => Subjects.Add(n.Data));
     main.KeyWordList.ForEach(n => Keywords.Add(n.Data));
     main.CoreCapabilities.ForEach(n => CoreCapabilities.Add(n.Data));
 }
        public CreateBlogModel()
        {
            AuthorClass a = new AuthorClass()
            {
                First_Name = "Thomas",
                Last_Name  = "Keigh",
                Email      = "*****@*****.**",
            };

            AuthorClass b = new AuthorClass()
            {
                First_Name = "Boris",
                Last_Name  = "Smart",
                Email      = "*****@*****.**",
            };

            AuthorClass c = new AuthorClass()
            {
                First_Name = "McGill",
                Last_Name  = "Trent",
                Email      = "*****@*****.**",
            };

            Authors.Add(a);
            Authors.Add(b);
            Authors.Add(c);
        }
Beispiel #13
0
 public void AddAuthor(Author author)
 {
     if (author != null)
     {
         Authors.Add(author);
     }
 }
        private void AddAuthor_Click(object sender, RoutedEventArgs e)
        {
            var addAuthorWindow = new AddAuthorWindow();

            addAuthorWindow.AuthorAdded += (_, e) => Authors.Add(e.Entity);
            addAuthorWindow.Show();
        }
        private void addNewAuthor(object sender, RoutedEventArgs e)
        {
            var g = new Author();

            Authors.Add(g);
            lv_DSTacGia.SelectedItem = g;
            lv_DSTacGia.ScrollIntoView(g);
        }
Beispiel #16
0
    static void Main()
    {
        Authors authors = new Authors();

        authors.Add(new Person("James", 31));
        authors.Add(new Person("Roger", 21));
        authors.Add(new Person("Ben", 21));
        authors.Add(new Person("Richard", 21));
        authors.Add(new Person("Teun", 21));

        Person author = authors["James"];

        Console.WriteLine(author.Name + " - " + author.Age.ToString());
        author.Age = 21;
        author     = authors["James"];
        Console.WriteLine(author.Name + " - " + author.Age.ToString());
    }
Beispiel #17
0
        public CreateBlog()
        {
            Model.AuthorModel FristAuthor = new AuthorModel()
            {
                Given_name  = "Richard",
                Last_name   = "Flow",
                Birth_date  = new DateTime(1990, 06, 27),
                Email       = "*****@*****.**",
                Website     = "www.abc.com",
                Phone       = "8888554455",
                Country     = "Canada",
                Province    = "Ontario",
                Postal_code = "1424115"
            };

            Model.AuthorModel SecondAuthor = new AuthorModel()
            {
                Given_name  = "Richard",
                Last_name   = "Jhnonson",
                Birth_date  = new DateTime(1992, 06, 27),
                Email       = "*****@*****.**",
                Website     = "www.abc1.com",
                Phone       = "8888554465",
                Country     = "US",
                Province    = "ANY",
                Postal_code = "1524115"
            };
            Model.AuthorModel ThirdAuthor = new AuthorModel()
            {
                Given_name  = "Michael",
                Last_name   = "Jhnonson",
                Birth_date  = new DateTime(1980, 06, 27),
                Email       = "*****@*****.**",
                Website     = "www.abc12.com",
                Phone       = "88885544652",
                Country     = "India",
                Province    = "ANY1",
                Postal_code = "15241152"
            };

            Model.AuthorModel FourthAuthor = new AuthorModel()
            {
                Given_name  = "Stephen",
                Last_name   = "Jhnonson",
                Birth_date  = new DateTime(1982, 06, 27),
                Email       = "*****@*****.**",
                Website     = "www.abc121.com",
                Phone       = "888855446521",
                Country     = "Pakistan",
                Province    = "Baluchistan",
                Postal_code = "152141152"
            };

            Authors.Add(FristAuthor);
            Authors.Add(SecondAuthor);
            Authors.Add(ThirdAuthor);
            Authors.Add(FourthAuthor);
        }
Beispiel #18
0
 public Book(string WarandPeace, string LeoTolstoy, string P1225, string B28401, string TheRussianMessenger, string cost)
 {
     Title = WarandPeace;
     Authors.Add(LeoTolstoy);
     Pages     = P1225;
     SKU       = B28401;
     Publisher = TheRussianMessenger;
     Price     = cost;
 }
Beispiel #19
0
 public void GetAuthorsFromTextBox()
 {
     foreach (Control textBox in panelAuthors.Controls)
     {
         if (textBox is TextBox)
         {
             Authors.Add(textBox.Text);
         }
     }
 }
Beispiel #20
0
        public void SetAuthor(Author author)
        {
            if (Authors == null)
            {
                Authors = new HashSet <Author>();
            }

            Authors.Clear();
            Authors.Add(author);
        }
Beispiel #21
0
        private void RunSelect()
        {
            Authors.Clear();
            ObservableCollection <SmallAuthorObject> tmp = new ObservableCollection <SmallAuthorObject>(DatabaseAccess.SelectAuthorList(FirstName, LastName));

            foreach (var item in tmp)
            {
                Authors.Add(item);
            }
        }
Beispiel #22
0
 public void ProcessParamsList(List <Param> paramsList)
 {
     for (int i = 0; i < paramsList.Count; i++)
     {
         if (paramsList[i] is AuthorParam authorParam)
         {
             Authors.Add(authorParam.Text);
         }
     }
 }
Beispiel #23
0
        private void FillLibrary()
        {
            Genres.Add(new Genre {
                Id = 1, Name = "Fantasy"
            });
            Genres.Add(new Genre {
                Id = 2, Name = "Science fiction"
            });
            Genres.Add(new Genre {
                Id = 3, Name = "Textbook"
            });

            Books.Add(new Book {
                Id = 1, Title = "Hobbit", AuthorId = 1, PublishingDate = new DateTime(1937, 9, 21), GenreId = 1, Pages = 320
            });
            Books.Add(new Book {
                Id = 2, Title = "The Fellowship of the Ring", AuthorId = 1, PublishingDate = new DateTime(1954, 7, 29), GenreId = 1, Pages = 398
            });
            Books.Add(new Book {
                Id = 3, Title = "The Two Towers", AuthorId = 1, PublishingDate = new DateTime(1954, 11, 11), GenreId = 1, Pages = 327
            });
            Books.Add(new Book {
                Id = 4, Title = "Thw Return of the King", AuthorId = 1, PublishingDate = new DateTime(1955, 10, 20), GenreId = 1, Pages = 412
            });

            Books.Add(new Book {
                Id = 5, Title = "Pro C# 2010 and the .NET 4 Platform", AuthorId = 3, PublishingDate = new DateTime(2010, 5, 12), GenreId = 3, Pages = 1752
            });
            Books.Add(new Book {
                Id = 6, Title = "Pro VB 2010 and the .NET 4.0 Platform", AuthorId = 3, PublishingDate = new DateTime(2010, 10, 18), GenreId = 3, Pages = 1800
            });
            Books.Add(new Book {
                Id = 7, Title = "COM and .NET Interoperability", AuthorId = 3, PublishingDate = new DateTime(2002, 4, 24), GenreId = 3, Pages = 816
            });

            Books.Add(new Book {
                Id = 8, Title = "Remade", AuthorId = 2, PublishingDate = new DateTime(2011, 9, 20), GenreId = 2, Pages = 1056
            });
            Books.Add(new Book {
                Id = 9, Title = "Zodiac", AuthorId = 2, PublishingDate = new DateTime(1988, 7, 10), GenreId = 2, Pages = 283
            });
            Books.Add(new Book {
                Id = 10, Title = "Anathem", AuthorId = 2, PublishingDate = new DateTime(2008, 9, 9), GenreId = 2, Pages = 928
            });

            Authors.Add(new Author {
                Country = "England", Id = 1, FirstName = "John Ronald Reuel", LastName = "Tolkien"
            });
            Authors.Add(new Author {
                Country = "USA", Id = 2, FirstName = "Neal", LastName = "Stephenson"
            });
            Authors.Add(new Author {
                Country = "USA", Id = 3, FirstName = "Andrew", LastName = "Troelsen"
            });
        }
Beispiel #24
0
 public void FromXML(XElement xmlElement)
 {
     foreach (var element in xmlElement.Descendants("Author"))
     {
         Authors.Add((string)element.Value);
     }
     foreach (var element in xmlElement.Descendants("Reader"))
     {
         Readers.Add((string)element.Value);
     }
 }
Beispiel #25
0
        void readDB()
        {
            foreach (var a in db.Table <Author>())
            {
                Authors.Add(a);
            }

            foreach (var s in db.Table <Song>())
            {
                Songs.Add(s);
            }
        }
Beispiel #26
0
 public Book(string bookName, DateTime publicationDate, BookCategory category, IList <Author> authors, string description = null)
 {
     ValidateInput(bookName, publicationDate, category, description, authors);
     foreach (var author in authors)
     {
         var authorToBook = new AuthorToBook(this, author);
         Authors.Add(authorToBook);
     }
     Category        = category;
     Name            = bookName;
     PublicationDate = publicationDate;
 }
 public void SaveAuthor(Author author)
 {
     author = new Author
     {
         FirstName    = author.FirstName,
         LastName     = author.LastName,
         AuthorId     = GetNewId(),
         EmailAddress = author.EmailAddress,
         Salary       = author.Salary,
         City         = author.City
     };
     Authors.Add(author);
 }
Beispiel #28
0
        /// <summary>
        ///     Defines what happens when the page is navigated on.
        /// </summary>
        /// <param name="parameter">parameter.</param>
        /// <param name="mode">navigation mode.</param>
        /// <param name="state">state.</param>
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            //Deciding if the book is searched by id or name.
            int intParam = 0;

            if (int.TryParse(parameter.ToString(), out intParam))
            {
                var bookId  = (int)parameter;
                var service = new BookService();
                Book = await service.GetBookAsync(bookId);
            }
            else
            {
                var bookName = (string)parameter;
                var service  = new BookService();

                var booksList = await service.GetBookAsync(bookName);

                foreach (var item in booksList)
                {
                    Book = item;
                }
            }

            //If no such book is found, navigate the user to the not found page.
            if (Book == null)
            {
                NavigateToNotFoundPage();
                return;
            }

            //Fill the lists on the UI, transforming uris if needed.
            foreach (string authorName in Book.authors)
            {
                Authors.Add(new Author(authorName));
            }

            foreach (string characterUri in Book.characters)
            {
                TransformUriToCharacter(characterUri, Characters);
            }

            foreach (string characterUri in Book.povCharacters)
            {
                TransformUriToCharacter(characterUri, PoVCharacters);
            }

            await base.OnNavigatedToAsync(parameter, mode, state);
        }
Beispiel #29
0
 public AuthorModel()
 {
     Authors.Add(new AuthorModel {
         AuthorId = 1, AuthorName = "J.K. Rowling"
     });
     Authors.Add(new AuthorModel {
         AuthorId = 2, AuthorName = "Stephen Hawking"
     });
     Authors.Add(new AuthorModel {
         AuthorId = 3, AuthorName = "R.L. Stein"
     });
     Authors.Add(new AuthorModel {
         AuthorId = 4, AuthorName = "Graham Hancock"
     });
 }
Beispiel #30
0
        /// <summary>
        /// This method seach author in the library by name.
        /// If there is not entered name in library method adds new author to the library with entered name.
        /// </summary>
        /// <param name="authorName">author name</param>
        /// <returns>returns author</returns>
        private Author GetAuthor(string authorName)
        {
            foreach (Author a in Authors)
            {
                if (a.Name == authorName)
                {
                    return(a);
                }
            }
            Author author = new Author(authorName);

            Authors.Add(author);
            authorsDao.Save(Authors);
            return(author);
        }