public async Task <ActionResult <CommentPostModel> > GetCommentPostModel(int id) { if (id <= 0) { return(NotFound()); } var commentPostModel = await _commentPostServices.GetByIdAsync(id); if (commentPostModel == null) { return(NotFound()); } return(commentPostModel); }
public async Task <IActionResult> DeleteComment(int id) { try { var userId = await GetUserIdentityAsync(); var commentPostModel = await _commentPostServices.GetByIdAsync(id); if (userId == commentPostModel.IdentityUser) { await _commentPostServices.DeleteAsync(id); } return(RedirectToAction("Index", "Home")); } catch (Exception ex) { return(RedirectToAction("Index", "Home")); } }