public ActionResult DeleteComment(Guid id, ConfirmModel model, string name) { if (ModelState.IsValid) { if (CommentModel.Delete(id)) { logger.Info("Удаление комментария " + id); return(RedirectToAction("UserComments", "Admin", new { name = name })); } else { logger.Error("Ошибка удаления комментария " + id); if (Request.IsAjaxRequest()) { return(PartialView("DeleteComment")); } return(View()); } } else { if (Request.IsAjaxRequest()) { return(PartialView("DeleteComment")); } return(View()); } }
public ActionResult Delete(int commentId) { CommentModel cmModel = new CommentModel(); if (cmModel.Delete(commentId) > 0) { return(Json(new { message = "SUCCESS" })); } else { return(Json(new { message = "FAIL" })); } }
public IActionResult Delete(int id) { if (ModelState.IsValid) { var model = new CommentModel(); try { var provider = model.Delete(id); model.Response = new ResponseModel($"Post {provider} successfully deleted.", ResponseType.Success); return(RedirectToAction("Index")); } catch (Exception ex) { model.Response = new ResponseModel("Comment Delete failed.", ResponseType.Failure); // error logger code _logger.LogError($"Comment Delete 'Failed'. Excption is : {ex.Message}"); } } return(RedirectToAction("index")); }