public async Task <IActionResult> Delete(int id) { var post = new Post { Id = id }; _postsContext.Attach(post).State = EntityState.Deleted; try { await _postsContext.SaveChangesAsync(); return(Ok()); } catch (DbUpdateConcurrencyException) { return(NotFound()); } }