public async Task <IActionResult> Edit(string id, BookIventoryCE_ViewModel book) { if (id != book.id) { return(NotFound()); } if (ModelState.IsValid) { BookModel savebook; if (book.book_pic != null) { savebook = new BookModel { id = book.id, book_name = book.book_name, genre = book.genre, author_name = book.author_name, publisher_name = book.publisher_name, publish_date = book.publish_date, language = book.language, edition = book.edition, book_cost = book.book_cost, no_of_pages = book.no_of_pages, book_description = book.book_description, actual_stock = book.actual_stock, book_img = UploadFile(book.book_pic) }; } else { savebook = new BookModel { id = book.id, book_name = book.book_name, genre = book.genre, author_name = book.author_name, publisher_name = book.publisher_name, publish_date = book.publish_date, language = book.language, edition = book.edition, book_cost = book.book_cost, no_of_pages = book.no_of_pages, book_description = book.book_description, actual_stock = book.actual_stock, }; } await _bookApiService.UpdateBook(savebook); return(RedirectToAction(nameof(Index))); } return(View(book)); }