Question: what to say to a friend that got fired?
Answer: I'm so sorry to hear the news. I know how much time you devoted there. ... 
I understand how scared (or angry, frustrated or sad) you're feeling. ... 
Do you want to talk about it?
Do you want to get together?
What do you need from me?
How can I help?
Everything happens for a reason.
That's horrible news!