I have a Asus model X540N laptop that switches off automatically with no warning and stops working. It also won't function or switch on when not connected to a charger
Sounds like your battery needs replacing. I would start there as many laptops can be quite temperamental if they do not have a functioning battery installed.