예제 #1
0
        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));
            }
        }
예제 #2
0
 public string CreateBook(Book newBook)
 {
     _library.AddNewBook(newBook);
     return("Book added");
 }