public async Task RemovePostAsync(int id) { var post = await context.Posts.FindAsync(id); if (post == null) { throw new NotFoundException(ErrorCode.ResourceNotFound, "post was not found"); } context.Remove(post); await context.SaveChangesAsync(); }