public async Task <ActionResult <Post> > GetPost(int id) { var post = await _postServices.GetByIdAsync(id); if (post == null) { return(NotFound()); } return(post); }
public async Task <ActionResult> Delete(int id) { try { var userId = await GetUserIdentityAsync(); var postModel = await _postServices.GetByIdAsync(id); if (userId == postModel.IdentityUser) { await _postServices.DeleteAsync(id, null); } return(RedirectToAction("Index", "Home")); } catch (Exception ex) { return(RedirectToAction("Index", "Home")); } }