Exemple #1
0
        public ActionResult Create(string title, int quantity, int authorId)
        {
            if (title.Length < 1 || quantity < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            var authorRepo = new AuthorRepository();
            var bookToAdd = new Book();

            bookToAdd.Title = title;
            bookToAdd.Quantity = quantity;

            var bookRepo = new BookRepository();
            bookRepo.AddBook(bookToAdd);

            authorRepo.AddBookToAuthor(authorId, bookToAdd);

            return RedirectToAction("Create");
        }