public async Task <IActionResult> Create(BooksCreateViewModel model) { if (ModelState.IsValid) { Book book = new Book { Price = model.Price, ISBN = model.ISBN, Author = model.Author, Pages = model.Pages, Title = model.Title }; _context.Add(book); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }
// GET: Books/Create public IActionResult Create() { BooksCreateViewModel model = new BooksCreateViewModel(); return(View(model)); }