Esempio n. 1
0
 private bool FindBook(string bookName, Author[] authors)
 {
     Guid[] authorsIds = authors.Select(x => x.AuthorId).ToArray();
     //var exist = context.Books.Any(b => b.Name.ToLower() == bookName.ToLower() && b.Authors.Any(a => authors.Contains(a)));
     var exist = context.Books.Any(b => b.Name.ToLower() == bookName.ToLower() && b.Authors.Any(a => authorsIds.Contains(a.AuthorId)));
     return exist;
 }
Esempio n. 2
0
 private void AddAuthorToDatabase(string authorName)
 {
     Author author = new Author();
     author.AuthorId = Guid.NewGuid();
     author.Name = authorName;
     author.PhotoUpdated = DateTime.Now;
     context.Authors.Add(author);
     if (this.authors == null)
     {
         this.authors = new List<Author>();
     }
     this.authors.Add(author);
 }
Esempio n. 3
0
 public AuthorsDataFromWiki(Entities context, Author author)
 {
     if (AuthorNameIsValidated(author.Name))
     {
         AuthorPage authorPage = new AuthorPage(author.Name);
         ProcessAuthorPage processAuthorPage = new ProcessAuthorPage(authorPage.AuthorPageUrl, authorPage.AuthorPageHtmlDocument);
         if (processAuthorPage.AuthorData != null)
         {
             UpdateAuthorResources(context, author, processAuthorPage.AuthorData);
         }
         else
         {
             UpdateAuthorState(context, author);
         }
     }
     else
     {
         UpdateAuthorState(context, author);
     }
 }
Esempio n. 4
0
 private void UpdateAuthorResources(Entities context, Author author, AuthorData authorData)
 {
     string sql = string.Empty;
     if (!string.IsNullOrEmpty(authorData.Biography))
     {
         author.Biography = authorData.Biography;
         author.NameFromWiki = authorData.NameFromWiki;
         author.Photo = authorData.AuthorImage;
         author.PhotoUpdated = DateTime.Now;
         if (authorData.BornDate > new DateTime(1753, 1, 1))
         {
             author.BirthDate = authorData.BornDate;
         }
         if (authorData.DeathDate > new DateTime(1753, 1, 1))
         {
             author.DeathDate = authorData.DeathDate;
         }
         author.SourceUrl = authorData.OriginalUrl;
         author.FromWiki = true;
     }
 }
Esempio n. 5
0
 private void UpdateAuthorState(Entities context, Author author)
 {
     author.PhotoUpdated = DateTime.Now;
     author.FromWiki = true;
 }