First and foremost, the body is inefficient at performing both activities at the same time. The only times when both happen at peak efficiency is when the person is just a beginner who is starting bodybuilding, in which case, weight training is such a new stimulus to the body that muscle gain and fat loss happen extremely efficiently. The second case is when coming back after a period of no weight training in which case the body is just regaining muscle tissue that has been previously built. If God forbid you get the flu and couldn't train for 3 weeks, once you come back you will experience simultaneous accelerated muscle gain and fat loss.
If Above 10% Bodyfat for Males or 12% for Women, Concentrate on Losing Fat First
Having said that, my recommendation is that if you are above 10% body fat for men and 12% for women, try to concentrate first on getting below that level while retaining, or even gaining, a moderate amount of muscle tissue. This is accomplished by following a diet that is composed of 40% carbs, 40% proteins and 20% fats . This ratio works very well for most people except for hardgainers that can get away with eating more carbs and fats. Carbs should come mainly from complex slow releasing sources such as oatmeal, grits, brown rice, and sweet potatoes, in combination with fibrous sources such as green beans and broccoli. Proteins should come mainly from chicken, turkey, tuna, turkey, salmon, and lean red meats. Since you are focused on reducing body fat, dairy products and fruits need to be eliminated at this time, not because they are not healthy but due to the fact that the type of simple carbs contained in these foods may slow down fat loss. Finally, you need some fats and these should come on the form of fish oils, flaxseed oil or extra virgin canned olive oil.
As far as the amounts of nutrients required to lose fat, a good starting point is 1 gram of protein per pound of bodyweight, 1 gram of carbs per pound of bodyweight, and 3 tablespoons of good fats per day for men and 1.5 for women.
Once Lean Enough It Is Time To Gain Muscle
Once below 10% body fat (12% for women), the athlete can go ahead and start on a bulk up cycle. All that needs to be done then is just increase your nutrient intake to 1.5 grams of protein per pound bodyweight, 1.5-2 grams of carbs per pound and keep the essential fats at 3 tablespoons per day for guys and 1.5 for women. The athlete should continue to bulk up until a level of 10% body fat is exceeded. At that point, calories need to be reduced again. Understand, that when eating more calories than what the body burns on any given day, some of those calories will be deposited as body fat. However, if your training is right on the money, most of the calories will be used for energy and muscle production.
Weight Training and Cardio
Weight training wise, 4-5 sessions of 45 minutes to 1 hour, at the most, in the gym should get the job done. A good strategy to avoid stagnation is to periodize, which in other words is to change your workout parameters like sets, reps and rest in between sets in a logical and orderly fashion that elicits the most response for the body. So for instance you can do 4 weeks of training using higher reps, such as 12-15, and short periods of rest in between sets, like 60 seconds, and then follow that with 4 weeks of lower rep work (in the range of 8-10) with longer rest in between sets 90 seconds to 2 minutes . As far as cardiovascular exercise, around 5-6 sessions of 30-45 minutes when trying to cut down to below 10% body fat and around 2-3 sessions of 20-30 minutes when trying to add mass should suffice. Now, if you are a hardgainer, which in other words is a naturally skinny person that has problems gaining weight, then no cardio is recommended and also a higher amount of carbohydrates and fats is also advised.
So in a nutshell, alternating between higher calorie periods and lower calorie periods along with a properly periodized routine is the key for consistent progress in terms of muscle gain and fat loss. In this manner, you can gain muscle while staying in good shape throughout the year.