/// <summary> /// Checks whether the parts sum up correctly. /// </summary> /// <returns><c>true</c> if all parts sum up correctly, <c>false</c> otherwise.</returns> public Boolean Verify() { Boolean result = true; foreach (var entry in data) { result &= entry.Verify(); } var municipal = data.FirstOrDefault(x => x.type == PopulationDataType.municipal); var rural = data.FirstOrDefault(x => x.type == PopulationDataType.nonmunicipal); if ((municipal != null) && (rural != null)) { result &= TotalPopulation.VerifySum(municipal, rural); } var collectivehouseholds = data.FirstOrDefault(x => x.type == PopulationDataType.collectivehouseholds); var privatehouseholds = data.FirstOrDefault(x => x.type == PopulationDataType.privatehouseholds); if ((collectivehouseholds != null) && (privatehouseholds != null)) { result &= TotalPopulation.VerifySum(collectivehouseholds, privatehouseholds); } var agricultural = data.FirstOrDefault(x => x.type == PopulationDataType.agricultural); var nonagricultural = data.FirstOrDefault(x => x.type == PopulationDataType.nonagricultural); if ((agricultural != null) && (nonagricultural != null)) { result &= TotalPopulation.VerifySum(agricultural, nonagricultural); } return(result); }
/// <summary> /// Checks whether the parts sum up correctly. /// </summary> /// <returns><c>true</c> if all parts sum up correctly, <c>false</c> otherwise.</returns> public Boolean Verify() { Boolean result = true; var validData = data.Where(x => x.valid); foreach (var entry in validData) { result &= entry.Verify(); } var municipal = validData.FirstOrDefault(x => x.type == PopulationDataType.municipal); var rural = validData.FirstOrDefault(x => x.type == PopulationDataType.nonmunicipal); if ((municipal != null) && (rural != null)) { result &= TotalPopulation.VerifySum(municipal, rural); } var collectivehouseholds = validData.FirstOrDefault(x => x.type == PopulationDataType.collectivehouseholds); var privatehouseholds = validData.FirstOrDefault(x => x.type == PopulationDataType.privatehouseholds); if ((collectivehouseholds != null) && (privatehouseholds != null)) { result &= TotalPopulation.VerifySum(collectivehouseholds, privatehouseholds); } var sanitary = validData.FirstOrDefault(x => x.type == PopulationDataType.sanitary); var urbanSanitary = validData.FirstOrDefault(x => x.type == PopulationDataType.urbansanitary); var ruralSanitary = validData.FirstOrDefault(x => x.type == PopulationDataType.ruralsanitary); if ((urbanSanitary != null) && (ruralSanitary != null) && (sanitary != null)) { result &= sanitary.VerifySum(collectivehouseholds, privatehouseholds); } var agricultural = validData.FirstOrDefault(x => x.type == PopulationDataType.agricultural); var nonagricultural = validData.FirstOrDefault(x => x.type == PopulationDataType.nonagricultural); if ((agricultural != null) && (nonagricultural != null)) { result &= TotalPopulation.VerifySum(agricultural, nonagricultural); } var thai = validData.FirstOrDefault(x => x.type == PopulationDataType.thai); var foreigner = validData.FirstOrDefault(x => x.type == PopulationDataType.foreigner); if ((thai != null) && (foreigner != null)) { result &= TotalPopulation.VerifySum(thai, foreigner); } else if (thai != null) { result &= TotalPopulation.VerifyLessOrEqual(thai); } return(result); }