public async Task RemoveComment(int commentId) { Comment comment = repository.Comments .FirstOrDefault(c => c.Id == commentId); string cFor = comment.For; int cForId = comment.ForId; repository.DeleteComment(comment.Id); await Clients.All.SendAsync("CommentRemove", commentId, cFor, cForId); }
public IActionResult DeleteComment(int commentId, string returnUrl) { Comment comment = repository.Comments .FirstOrDefault(c => c.Id == commentId); if (comment != null) { Comment result = repository.DeleteComment(comment.Id); return(Redirect(returnUrl)); } else { //TODO: errror return(RedirectToAction("Error", "Error", new { err = "error name" })); } }