private void EnergyPaymentContextCustomerChanged(EnergyCustomer customer) { CustomerNumber.Value = customer != null ? (uint)customer.Number : 0; IsCustomerNumberFocused.Value = customer == null; CustomerName.Value = customer?.Name ?? string.Empty; CustomerAddress.Value = customer?.Address ?? string.Empty; CustomerIsClosed.Value = customer != null ? (bool?)customer.IsClosed : null; CustomerEmail.Value = customer?.Email ?? string.Empty; PreviousDayValue.Value = customer != null ? (uint)customer.DayValue : 0; PreviousNightValue.Value = customer != null ? (uint)customer.NightValue : 0; CurrentDayValue.Value = PreviousDayValue.Value; CurrentNightValue.Value = PreviousNightValue.Value; UpdateDayDeltaValue(); UpdateNightDeltaValue(); SelectedPaymentReason.Value = PaymentReasons.FirstOrDefault(); Cost.Value = 0; Description.Value = string.Empty; IsNormative.Value = customer != null?customer.IsNormative() : false; IsPaymentEnable.Value = customer != null; IsDayValueActive.Value = !IsNormative.Value && IsPaymentEnable.Value; IsNightValueActive.Value = (customer?.IsTwoTariff() ?? false) && IsPaymentEnable.Value; }
public static bool IsTwoTariff(this EnergyCustomer customer) { return(customer.DayValue > 0 && customer.NightValue > 0); }
public static bool IsNormative(this EnergyCustomer customer) { return(customer.DayValue <= 0 && customer.NightValue <= 0); }