public decimal ElectroDiscTotal(ElectroBill electroBill, Tariff tariff) { decimal totalValue = 0; List<decimal> tariffStr = tariff.ParseDiscString(tariff.ElectroDiscString); if (tariffStr.Count == 5) { if (electroBill.ElectroUsage >= tariffStr[0]) { totalValue += tariffStr[0] * tariffStr[2]; if (electroBill.ElectroUsage < tariffStr[1]) { totalValue += (electroBill.ElectroUsage - tariffStr[0]) * tariffStr[3]; } else { totalValue += ((tariffStr[1] - tariffStr[0]) * tariffStr[3]) + ((electroBill.ElectroUsage - tariffStr[1]) * tariffStr[4]); } } else { return electroBill.ElectroUsage * tariffStr[2]; } return totalValue; } return totalValue; }
public RedirectToRouteResult AddElectrobillToCheckout(Checkout order, ElectroBill electroBill, string returnUrl) { if (electroBill != null) { if (order.chosenTariff == null) { order.chosenTariff = tariffRepo.Tariffs .FirstOrDefault(p => p.Id != null); } order.InitCalc(new ValueCalculator()); order.SetElectro(electroBill); } return RedirectToAction("Index", new { returnUrl }); }
public ViewResult AddElectrobillToCheckout() { ElectroBill electroBill = new ElectroBill(); return View(electroBill); }
public decimal ElectroTotal(ElectroBill electroBill, Tariff tariff) { return electroBill.ElectroUsage * tariff.ElectroTariff; }