public PartialViewResult GetDetail(string keyWord, string productModel) { var dtoResults = GovDataFactory.MixGovPcDataRepository.GetMixGovPcDataDtosByKeyWord(keyWord); var dtoResult = dtoResults.Where(w => w.product_model == productModel && w.data_from?.Trim().ToUpper() == "PCHOME").FirstOrDefault(); if (dtoResult == null) { dtoResult = dtoResults.Where(w => w.product_model == productModel && w.data_from?.Trim().ToUpper() == "MOMO").FirstOrDefault(); } EnergyEfficiencyModels energyEfficiencyModels = null; if (dtoResult != null) { energyEfficiencyModels = JsonConvert.DeserializeObject <EnergyEfficiencyModels>(dtoResult?.test_report_of_energy_efficiency); energyEfficiencyModels.detailUri = dtoResult?.detailUri; energyEfficiencyModels.efficiency_rating = dtoResult.efficiency_rating; energyEfficiencyModels.originprice = dtoResult.originprice; energyEfficiencyModels.keyWord = keyWord; energyEfficiencyModels.efficiency_benchmark = dtoResult?.efficiency_benchmark; energyEfficiencyModels.dayCost = dtoResult.DailyCost; energyEfficiencyModels.monthCost = dtoResult.MothlyCost; } else { energyEfficiencyModels = new EnergyEfficiencyModels(); } return(PartialView("_GetDetail", energyEfficiencyModels)); }
/// <summary> /// Energy Efficiency Handler /// </summary> /// <param name="strEnergyEfficiency"></param> /// <param name="keyWord"></param> /// <returns></returns> private string EnergyEfficiencyHandler(string strEnergyEfficiency, string keyWord) { string result = string.Empty; string htmlWrap = "<br/>"; StringBuilder stringBuilder = new StringBuilder(); if (!string.IsNullOrWhiteSpace(strEnergyEfficiency)) { EnergyEfficiencyModels energyEfficiencyModels = JsonConvert.DeserializeObject <EnergyEfficiencyModels>(strEnergyEfficiency); switch (keyWord) { case "冷暖空調": stringBuilder.Append("能源效率值EER:"); stringBuilder.Append(energyEfficiencyModels.EER); stringBuilder.Append(htmlWrap); stringBuilder.Append("冷氣季節性能因數CSPF:"); stringBuilder.Append(energyEfficiencyModels.CSPF); break; case "冰溫熱型開飲機": case "冰溫熱型飲水機": case "溫熱型開飲機": case "溫熱型飲水機": case "電熱水瓶": stringBuilder.Append("est24:"); stringBuilder.Append(energyEfficiencyModels.est24); break; case "除濕機": stringBuilder.Append("額定除濕能力:"); stringBuilder.Append(energyEfficiencyModels.rated_dehumidification_capacity); stringBuilder.Append(htmlWrap); stringBuilder.Append("能源因數值:"); stringBuilder.Append(energyEfficiencyModels.energy_factor_value); break; case "電冰箱": stringBuilder.Append("能源因數值:"); stringBuilder.Append(energyEfficiencyModels.energy_factor_value); break; default: break; } } result = stringBuilder.ToString(); return(result); }
private void CalculationCost(ref MixGovPcDataDto model) { decimal energyCost = default(decimal); decimal dayCost = default(decimal); decimal monthCost = default(decimal); EnergyEfficiencyModels energyEfficiencyModels = JsonConvert.DeserializeObject <EnergyEfficiencyModels>(model?.test_report_of_energy_efficiency); switch (model.key_word) { case "冷暖空調": energyCost = Convert.ToDecimal(energyEfficiencyModels.CSPF?.Split(' ').FirstOrDefault()); dayCost = energyCost * 24 * 4; monthCost = energyCost * 24 * 30 * 4; break; case "冰溫熱型開飲機": case "冰溫熱型飲水機": case "溫熱型開飲機": case "溫熱型飲水機": case "電熱水瓶": energyCost = Convert.ToDecimal(energyEfficiencyModels.est24?.Split(' ').FirstOrDefault()); dayCost = energyCost * 4; monthCost = dayCost * 30; break; case "除濕機": energyCost = (Convert.ToDecimal(energyEfficiencyModels.rated_dehumidification_capacity?.Split(' ').FirstOrDefault())) / (Convert.ToDecimal(energyEfficiencyModels.energy_factor_value?.Split(' ').FirstOrDefault())); dayCost = energyCost * 4; monthCost = dayCost * 30; break; case "電冰箱": energyCost = (Convert.ToDecimal(energyEfficiencyModels.effective_internal_volume?.Split(' ').FirstOrDefault())) / (Convert.ToDecimal(energyEfficiencyModels.energy_factor_value?.Split(' ').FirstOrDefault()));; monthCost = energyCost * 4; dayCost = monthCost / 30; break; default: break; } model.MothlyCost = monthCost; model.DailyCost = dayCost; }