You have to read the whole process of acquiring C-27 spartans, 1, Afghanistan was never involved in the procurement of those transport aircrafts 2, Afghanistan didn't chose to fly those junks 3, Afghanistan didn't had the authority of those millions of dollars which USA wasted on that aircraft 4, Afghanistan was not part of the contract between USA and Italian company 5, Afghanistan already said the aircraft doesn't suit the environment and mission.
So take Afghanistan out of it and put the blame on the real culprits!
Maintaining any aircraft for Afghanistan is difficult at the moment but no impossible! we are going ahead steadily and very soon we would have a fleet of fighter jets but the best for counter-insurgency is fighter propellers which is already on order (20 of it) and the pilots, maintenance crew etc.. are studying in USA, Turkey and UAE and Afghanistan.