I would like to ask there is it possible to run the
if
if
public bool GenerateCategory(List<AllFoodSpendList> allFoodSpendList,Sections section,) { if (section.Protein == true || section.Fats == true || section.Grains == true) { List<bool> report = new List<bool>(); //RUN ACTION WHEN THE IF IS TRUE if (section.Protein == true) { List< AllFoodSpendList> allFoodList = new List< AllFoodSpendList >(); foreach(var item in allFoodList.Where(x => x.Type == Protein)) { allFoodList .Add(new AllFoodSpendList () { Spend = item.Spend, Calori = item.Calori, }); } List< AllFoodSpendList> record = allFoodList.ToList(); proteinText = JsonConvert.SerializeObject(record); if(record.Count > 0) { report.Add(true); }else{ Report.Add(false); } } //RUN ACTION WHEN THE IF IS TRUE if (section.Fats == true) { List< AllFoodSpendList> allFoodList = new List< AllFoodSpendList >(); foreach(var item in allFoodList.Where(x => x.Type == Protein)) { allFoodList .Add(new AllFoodSpendList () { Spend = item.Spend, Calori = item.Calori, }); } List< AllFoodSpendList> record = allFoodList.ToList(); fatsText = JsonConvert.SerializeObject(record); if(record.Count > 0) { report.Add(true); }else{ Report.Add(false); } } //RUN ACTION WHEN THE IF IS TRUE if (section.Grains == true) { List< AllFoodSpendList> allFoodList = new List< AllFoodSpendList >(); foreach(var item in allFoodList.Where(x => x.Type == Protein)) { allFoodList .Add(new AllFoodSpendList () { Spend = item.Spend, Calori = item.Calori, }); } List< AllFoodSpendList> record = allFoodList.ToList(); grainsText = JsonConvert.SerializeObject(record); if(record.Count > 0) { report.Add(true); }else{ Report.Add(false); } } if (!report.Contains(false)) { return true; } return false; } }
Anonymous Asked question May 14, 2021
Recent Comments