public ActionResult Delete(BookViewModel book, string prevPageUrl) { if (book.Id <= 0) { throw new ArgumentException("Book ID is empty or <= 0"); } if (ModelState.IsValid) { _booksRepository.DeleteElem(BookConverter.ConvertViewModelToModel(book)); TempData["message"] = $"Книга \"{book.Title}\" успешно удалена"; return(RedirectToAction(nameof(HomeController.Index), nameof(HomeController).Replace("Controller", ""))); } else { return(View(new ActionBooksPagesViewModel { Book = book, Genres = new SelectList(_genresRepository.GetAllGenres(), nameof(Genre.Id), nameof(Genre.Title), _genresRepository.GetAllGenres().FirstOrDefault(g => g.Id == book.GenreId)), PrevPageUrl = prevPageUrl })); } }