Esempio n. 1
0
        public ActionResult Create(BookModels book)
        {
            try
            {
                using (var repo = new BookRepository())
                {
                    repo.Create(book);
                    book.Id = repo.GetBookByTitle(book.Title);
                }

                foreach (var author in book.SelectedAuthors)
                {
                    using (var repo = new BookRepository())
                    {
                        repo.BindAuthorToBook(book.Id, author);
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }