private void TransferModelToTaskItem(DietPlan dietPlan) { TodayTasks = new List <DietPlanTaskItem>(); foreach (var subDietPlan in dietPlan.SubDietPlans) { DietPlanTaskItem dietPlanTaskItem = new DietPlanTaskItem() { Id = subDietPlan.Id, Score = subDietPlan.Score, StartTime = subDietPlan.StartTime }; FoodTaskList foodTasks = new FoodTaskList(); //FoodTaskItem[] foodTasks = new FoodTaskItem[] { }; foreach (var dietPlanItem in subDietPlan.DietPlanItems) { FoodTaskItem foodTaskItem = new FoodTaskItem() { Id = dietPlanItem.Id, Amount = (int)dietPlanItem.Amount, Calorie = (int)dietPlanItem.Food.Calorie, FoodName = dietPlanItem.Food.Name }; foodTasks.Add(foodTaskItem); } dietPlanTaskItem.FoodTasks = foodTasks; TodayTasks.Add(dietPlanTaskItem); } }
private void TransferModelToTaskItem(DietPlan dietPlan) { TodayTasks = new List<DietPlanTaskItem>(); foreach (var subDietPlan in dietPlan.SubDietPlans) { DietPlanTaskItem dietPlanTaskItem = new DietPlanTaskItem() { Id = subDietPlan.Id, Score = subDietPlan.Score, StartTime = subDietPlan.StartTime }; FoodTaskList foodTasks = new FoodTaskList(); //FoodTaskItem[] foodTasks = new FoodTaskItem[] { }; foreach (var dietPlanItem in subDietPlan.DietPlanItems) { FoodTaskItem foodTaskItem = new FoodTaskItem() { Id = dietPlanItem.Id, Amount = (int)dietPlanItem.Amount, Calorie = (int)dietPlanItem.Food.Calorie, FoodName = dietPlanItem.Food.Name }; foodTasks.Add(foodTaskItem); } dietPlanTaskItem.FoodTasks = foodTasks; TodayTasks.Add(dietPlanTaskItem); } }