public ActionResult Delete(ComicBooksDeleteViewModel viewModel)
        {
            try {
                _comicBooksRepository.Delete(
                    viewModel.ComicBook.Id,
                    viewModel.ComicBook.RowVersion);

                TempData["Message"] = "Your comic book was successfully deleted!";

                return(RedirectToAction("Index"));
            }
            catch (DbUpdateConcurrencyException e) {
                string message = null;

                var entityPropertyValues = e.Entries.Single().GetDatabaseValues();

                if (entityPropertyValues == null)
                {
                    message = "Another user deleted this comicbook while you were attempting to delete it. Click 'Cancel' to return to the list.";

                    viewModel.ComicBookHasBeenDeleted = true;
                }
                else
                {
                    message = "The comicbook was updated by another user while you were attempting to delete it. If you still want to delete it, click 'Delete' again. Otherwise click 'Cancel' to navigate back to list.";

                    viewModel.ComicBook.RowVersion = ((ComicBook)entityPropertyValues.ToObject()).RowVersion;
                }

                ModelState.AddModelError(string.Empty, message);

                return(View(viewModel));
            }
        }
        public ActionResult Delete(ComicBooksDeleteViewModel viewModel)
        {
            try
            {
                _comicBooksRepository.Delete(viewModel.ComicBook.Id, viewModel.ComicBook.RowVersion);

                TempData["Message"] = "Your comic book was successfully deleted!";

                return(RedirectToAction("Index"));
            }
            catch (DbUpdateConcurrencyException ex)
            {
                string message = null;

                var entityPropertyValues = ex.Entries.Single().GetDatabaseValues();

                if (entityPropertyValues == null)
                {
                    message = "The comic book being deleted has been deleted by another user. Click the 'Cancel' Button to return to the list page.";

                    viewModel.ComicBookHasBeenDeleted = true;
                }
                else
                {
                    message = "The comic book being deleted has already been updated by another user. If you still want to delete the comic book than click the 'Delete' button again. Otherwise click the 'Cancel' button to return to the detail page.";

                    viewModel.ComicBook.RowVersion = ((ComicBook)entityPropertyValues.ToObject()).RowVersion;
                }

                ModelState.AddModelError(string.Empty, message);

                return(View(viewModel));
            }
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var comicBook = _comicBooksRepository.Get((int)id);

            if (comicBook == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new ComicBooksDeleteViewModel()
            {
                ComicBook = comicBook
            };

            return(View(viewModel));
        }