public ActionResult Create(CreateBookViewModel createBookViewModel) { if (ModelState.IsValid) { try { var book = new Book() { Title = createBookViewModel.Book.Title }; foreach (var authorId in createBookViewModel.SelectedAuthors) { book.AuthorId.Add(authorId); } bookService.AddNewBook(book); return(RedirectToAction(nameof(Index))); } catch { return(View()); } } return(View()); }
public void CanCreateUser() { var Book = new BookService(context); Data.Database.Entities.Book book = Book.AddNewBook("test"); context.SaveChanges(); book.Id.Should().NotBe(0); book.Name.Should().Be("test"); }
public override void AddNewValidEntityShouldBeSuccessful() { Assert.AreEqual(true, service.AddNewBook(book), "Expected validation to pass"); }