Exemple #1
0
        public async Task <ActionResult> Delete(Blogpost blogpost)
        {
            try {
                await _blogpostRepository.DeleteBlogpost(blogpost);

                return(RedirectToAction("Index"));
            }
            #region UpdateConcurrency Catch

            catch (DbUpdateConcurrencyException) {
                return(RedirectToAction("Delete", new { concurrencyError = true, id = blogpost.BlogpostId }));
            }

            #endregion
            #region RetryLimitExceeded Catch

            catch (RetryLimitExceededException /* dex */) {
                // TODO: Log the error (uncomment dex variable name and add a line here to write a log
                ModelState.AddModelError(string.Empty, "Unable to save changes. Try again and, if the problem persists, see your system administrator.");
                return(View("~/Views/Blogpost/Delete.cshtml", blogpost));
            }

            #endregion
        }