public IActionResult Add(AddShelfViewModel addShelfViewModel) { if (ModelState.IsValid) { //Create New Shelf Object: includes Title, Author, current page number, total page number Shelf newShelf = new Shelf() { BookTitle = addShelfViewModel.Book.BookTitle, AuthName = addShelfViewModel.AuthName, StartPage = addShelfViewModel.StartPage, TotalPage = addShelfViewModel.TotalPage }; //IF current page number !== total //ELSE //title, author, total page number context.Books.Add(newShelf); context.SaveChanges(); return(Redirect("/Home")); } return(View("Add", addBookViewModel)); }
public IActionResult AddBook() { AddShelfViewModel addShelfViewModel = new AddShelfViewModel(context.Books.ToList()); return(View(addShelfViewModel)); }