public ActionResult Delete(int commentId) { var articleComment = _articleCommentRepository.Read(commentId); if (articleComment == null) { return(HttpNotFound()); } try { _articleCommentRepository.Delete(articleComment); } catch { TempData["error"] = ProjectConfiguration.Get.DataErrorMessage; } return(RedirectToAction("Details", "Article", new { id = articleComment.ArticleId })); }
public ActionResult Delete(long id) { try { if (_repository.Delete(id) != EntityStates.Deleted) { throw new Exception(_errorGenerator.GetExceptionResponse <DataModels.ArticleComment>(ActionType.Delete)); } var messageResponse = _errorGenerator.GetMessageResponse <DataModels.ArticleComment>(ActionType.Delete, id, success: true); Log.Warning(messageResponse.LogTemplate, messageResponse.Message); return(new JsonResult(new { messageResponse.Message })); } catch (Exception ex) { var input = new { Id = id }; var messageResponse = _errorGenerator.GetMessageResponse <DataModels.ArticleComment, object>(ActionType.Delete, input, exception: ex); Log.Error(messageResponse.LogTemplate, messageResponse.Message, input); throw new Exception(messageResponse.Message); } }
public ActionResult Delete(int id, ArticleCommentModel articleComment) { _articleCommentRepository.Delete(id, articleComment); return(RedirectToAction(nameof(Index))); }