public async Task <AccountResult> UpdateBook(BookNameandIdViewModel bookAndIdViewModel) { var resultMessage = new AccountResult(); var oldBook = await _dataContext.Books.FindAsync(bookAndIdViewModel.Id); if (oldBook != null) { oldBook.bookName = bookAndIdViewModel.bookName ?? oldBook.bookName; } var success = _dataContext.SaveChanges() > 0; if (success) { return(resultMessage); } throw new Exception("Problem Saving Changes"); }
public async Task <ActionResult> UpdateBook(BookNameandIdViewModel bookViewModel) { var result = await _bookService.UpdateBook(bookViewModel); return(Ok(bookViewModel.bookName)); }