public IActionResult Create(BookViewModel newBook) { if (ModelState.IsValid) { var bookToCreate = new Book() { Title = newBook.Title, Author = newBook.Author, IsCheckedOut = false, Id = Guid.NewGuid() }; _library.AddNewBook(bookToCreate); return(RedirectToAction("Index")); } else { return(View("Form", newBook)); } }
public string CreateBook(Book newBook) { _library.AddNewBook(newBook); return("Book added"); }