Sorry to hear about your charging issues. From what you’re describing I would suggest first looking at the AC Adapter plug to make sure the tip that connects to your system is not damaged or bent preventing proper seating. If damaged I recommend it be replaced.
If the AC adapter looks good, check the socket on the system for damage/bent plastics and items stuck in the port preventing the AC plug from locking in place, making sure the center plastic cylinder is in place (should look something like the below image).
If this part is damaged I would suggest replacing the system board. As the problem sounds like a physical connection issue between the adapter and motherboard I would not recommend replacing the battery in your initial troubleshooting.