It's not so much the dog doesn't listen, more that he doesn't understand what you want him to do. Go back to basics and don't punish him when he toilets indoors. Double your vigilance and take every opportunity to put him outside to toilet. The crucial thing is to be present when he does toilet in the correct place, so that you can reward him. This makes him keener to repeat the performance to get another treat. Conversely, if you have been telling him off for indoor accidents he may already feel inhibited about going to the toilet in your presence, including when he goes outdoors. This is one reason why it's important not to punish for inappropriate toileting.
A training class is not there to train your dog. Its purpose is to teach you to train your dog so you will need to be committed to train your dog for short sessions (5 minutes) several times a day rather than just simply turn up for classes! This little bit of training everyday will be repaid with a lifetime of living with a well behaved dog. You will also learn to avoid problems before they begin as well as receive help to overcome any that you already have with your dog.
There are a lot of different ways to train your dog. You may choose to sign up for a dog training class, hire a professional dog trainer for private lessons, or even send your dog to board with a trainer. However, plenty of people successfully train their dogs on their own. It's a great way to save money on training costs, and a wonderful way to bond with your dog.
Many owners appear disappointed that their young puppy will not toilet when out on a walk, yet relieves itself the second it gets back home. This is because the puppy has been taught to toilet only at home (hopefully in its garden), and being creatures of habit, they often wait until they have returned home before evacuating their bladder and/ or bowels.