// GET: Books/Create public ActionResult Create() { BookCreateViewModel newBook = new BookCreateViewModel(); ViewBag.AllAuthors = UpdateAuthors.GetAllAuthors(db); ViewBag.AllGenres = UpdateGenres.GetAllGenres(db); return View(newBook); }
public static BookCreateViewModel ToViewModel(this Book book) { BookCreateViewModel newBook = new BookCreateViewModel(); newBook.Title = book.Title; newBook.PublicationDate = book.PublicationDate; newBook.UniqueNumber = book.UniqueNumber; newBook.Author = book.Author; newBook.SelectedGenre = book.Genre.GenreID; newBook.SelectedAuthor = book.Author.AuthorID; //return the ViewModel return newBook; }
// GET: TestView public ActionResult TestView(BookCreateViewModel book) { ViewBag.BookCreate = book; return View(); }