If, as you indicate, the seller agreed to have the work done and get the permit but failed to do so, you can sue him for breach of contract--for violating the terms of your agreeement. In a breach of contract case, you can sue for the costs the breach caused you: e.g. the cost to have the work properly done and permitted. You cannot sue for mental stress or the waste of your time--those are not recognizable "damages," or things you can sue for, in breach of contract cases. And you can only recover legal fees if the terms of a written agreement say that if one side sues the other and wins, the winner gets legal fees.