private void DeletePostFromDB(int id) { using (var db = new CommonContext()) { var post = db.posts.Find(id); if (post != null) { db.Remove(post); db.SaveChanges(); } } }