public void Update_Test() { var bookService = new BookServise(_connectionString); bookService.Create(new ViewEntities.Models.BookViewModel { Name = "-Test Update Book-", Author = "Test Author", YearOfPublishing = "1997" }); var allBooks = bookService.Get().ToList(); var oldBook = allBooks.FirstOrDefault(x => x.Name == "-Test Update Book-"); oldBook.Author = "New Author"; oldBook.Name = "-Test Update Book 2-"; oldBook.YearOfPublishing = "1234"; bookService.Update(oldBook); var result = bookService.Get(oldBook.Id); Assert.IsTrue(result.Author == "New Author"); Assert.IsTrue(result.Name == "-Test Update Book 2-"); Assert.IsTrue(result.YearOfPublishing == "1234"); bookService.Remove(oldBook.Id); }
public ActionResult EditBook(BookViewModel book) { List <PublicHouseViewModel> publicHouses = new List <PublicHouseViewModel>(); var bookToUpdate = _bookServise.Get(book.Id); bookToUpdate.PublicHouses = book.PublicHouses; if (book.Name == null) { return(HttpNotFound()); } _bookServise.Update(book); return(Json(book)); }