Welcome to YT

You've been given some great advice already...but I just wanted to add that I know it can be very frustrating trying to house-train a yorkie, but the key is to stay calm and re-inforce the positive behaviour (ie: when your yorkie pees/poops where you want him to), rather than punishing the negative. It is very similar to potty-training a toddler - it takes time and mistakes will be made that won't be solved by a tap on the butt. Yorkies (all dogs in fact) thrive on positive attention, and it sounds like your little guy got lots of this from your girlfriend and perhaps that's why a strong bond was formed.
Obedience classes are definitely a good idea....it's a very rewarding experience and will help form a bond between the two of you.
We are not born knowing how to raise dogs (or children for that matter), it's a learning process...one that's most easily achieved with a calm and positive attitude....so take a deep breath and start again....there is support here if you need it
Good luck! xxx