예제 #1
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;
 }
예제 #2
0
        private void ValidateInput(string bookName, DateTime publicationDate, BookCategory category, string description, IList <Author> authors = null)
        {
            if (string.IsNullOrWhiteSpace(bookName))
            {
                throw new ArgumentNullException($"Next field named: {nameof(bookName)} is null or empty");
            }
            if (publicationDate == null)
            {
                throw new ArgumentNullException($"{nameof(publicationDate)} is requared");
            }
            if (authors == null)
            {
                throw new ArgumentNullException($"{nameof(authors)} is requared");
            }
            if (category == null)
            {
                throw new ArgumentNullException($"{nameof(category)} is requared");
            }

            Description = description ?? "Without description";
        }