public static void CreateBookComplex(
            string title,
            IList<string> authors,
            string isbn,
            string price,
            string webSite,
            IList<ReviewInfo> allReviews)
        {
            using (BookstoreSystemEntities context 
                = new BookstoreSystemEntities())
            {
                Book newBook = new Book();

                newBook.Title = title;
                foreach (var item in authors)
                {
                    newBook.Authors.Add(CreateOrLoadAuthor(context, item));
                }

                newBook.ISBN = isbn;
                newBook.Price = Convert.ToDecimal(price);
                newBook.WebSite = webSite;
                CreteReview(context, allReviews);
                

                context.Books.Add(newBook);
                context.SaveChanges();
            }

            
        }
 public static void CreateBook(
     string author,
     string title,
     string isbn,
     string price,
     string webSite)
 {
     using (BookstoreSystemEntities context
         = new BookstoreSystemEntities())
     {
         Book newBook = new Book();
         newBook.Authors.Add(CreateOrLoadAuthor(context, author));
         newBook.Title = title;
         newBook.ISBN = isbn;
         newBook.Price = Convert.ToDecimal(price);
         newBook.WebSite = webSite;
         context.Books.Add(newBook);
         context.SaveChanges();
     }
 }
        public static Author CreateOrLoadAuthor(BookstoreSystemEntities context, string authorName)
        {
            Author exsistingAuthor =
                (from auth in context.Authors
                 where auth.AuthorName.ToLower() == authorName.ToLower()
                 select auth).FirstOrDefault();

            if (exsistingAuthor != null)
            {
                return exsistingAuthor;
            }
            else
            {
                Author newAuthor = new Author
                {
                    AuthorName = authorName
                };

                context.Authors.Add(newAuthor);
                context.SaveChanges();

                return newAuthor;
            }
        }