public async Task <IActionResult> DeletePost([FromBody] SimpleString id) { int PostID = Int32.Parse(id.Value); BlogUserIdentity user = await _userManager.FindByNameAsync(User.Identity.Name); var UsersBlog = await _appContext.Blogs.FirstOrDefaultAsync(ob => ob.BlogUserIdentity == user); var postToRemove = _appContext.Posts.FirstOrDefault(ob => ob.PostId == PostID); if (postToRemove != null && postToRemove.Blog == UsersBlog) { _appContext.Posts.Remove(postToRemove); await _appContext.SaveChangesAsync(); await _fileService.DeletePostDirectory(user, postToRemove.Title, postToRemove.DateOfPost); return(Ok()); } else// if post was not found or { return(Conflict()); } }