Ejemplo n.º 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;
 }
Ejemplo n.º 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";
        }