예제 #1
0
        public ActionResult Index(ModelBook model)
        {
            if (ModelState.IsValid)
            {
                Book book = new Book(model.Name, model.PublishDate, model.PageCount, model.ISBN);
                foreach (string VARIABLE in model.SelectedCeck)
                {
                    Author Find_Author = singelton.GetAuthors.Back_Author(Convert.ToInt32(VARIABLE));
                    book.Add_BookAutor(Find_Author);
                }

                Publisher pub = singelton.GetPublishers.Find(Publisher => Publisher.Id == Convert.ToInt32(model.RadioCeck));
                book.Add_BookPublicher(pub);
                singelton.Add_Book(book);
                ViewBag.Book = singelton.GetBooks;
                return(RedirectToAction("Show_Table"));
            }
            else
            {
                Show_RadioAndCeck();
                return(View());
            }
        }
예제 #2
0
        public ActionResult Index(ModelBook book)
        {
            if (ModelState.IsValid)
            {
                Book booksBook = new Book(book.Name, book.PublishDate, book.PageCount, book.ISBN);
                foreach (var VARIABLE in book.SelectedCeck)
                {
                    var find_Author = singelton.GetAuthors.Find(Author => Author.Id == Convert.ToInt32(VARIABLE));
                    booksBook.Add_Author(find_Author);
                }

                var find_Publisher =
                    singelton.GetPublishers.Find(Publisher => Publisher.Id == Convert.ToInt32(book.RadioCeck));
                booksBook.Add_BookPublicher(find_Publisher);
                singelton.Add_Book(booksBook);
                ViewBag.Books = singelton.GetBooks;
                return(RedirectToAction("Show_Table"));
            }
            else
            {
                Show_RadioAndCeck();
                return(View());
            }
        }