예제 #1
0
 private static List<RateViewItem> GetRateItems(Tariff tariff)
 {
     var counter = 0;
     var electricityRates = new List<RateViewItem>();
     foreach (var rate in tariff.Rates)
     {
         electricityRates.Add(new RateViewItem(counter, rate));
         counter++;
     }
     return electricityRates;
 }
예제 #2
0
        public void DisplayTariffRates(Tariff electricity, Tariff gas)
        {
            _view.IsVisible = true;

            List<RateViewItem> electricityRates = GetRateItems(electricity);
            _view.SelectedPlanElectricityRates = electricityRates.ToArray();

            List<RateViewItem> gasRates = GetRateItems(electricity);
            _view.SelectedPlanGasRates = gasRates.ToArray();

            _view.StandingChargeText = string.Format("Standing charge: {0:C}", electricity.StandingCharge);
        }
예제 #3
0
        private void ResultSelectedCallBack(ResultSelected resultSelected)
        {
            var queryElectricity = new GetTariffInfoForPlan(resultSelected.SupplierName,
                resultSelected.PlanKey,
                PaymentMethods.FixedMonthlyDirectDebit,
                Products.Electricity,
                resultSelected.Region);

            var queryGas = new GetTariffInfoForPlan(resultSelected.SupplierName,
                resultSelected.PlanKey,
                PaymentMethods.FixedMonthlyDirectDebit,
                Products.Electricity,
                resultSelected.Region);

            var state = new Tariff[2];

            queryElectricity.Execute(_restClient, tariff => CallDispatcher(() =>
            {
                lock (state)
                {
                    state[0] = tariff;
                    if (state[1] != null)
                    {
                        PublishTariffInformationFoundEvent(state);
                    }
                }
            }));

            queryGas.Execute(_restClient, tariff => CallDispatcher(() =>
            {
                lock (state)
                {
                    state[1] = tariff;
                    if (state[0] != null)
                    {
                        PublishTariffInformationFoundEvent(state);
                    }
                }
            }));
        }
예제 #4
0
 private void PublishTariffInformationFoundEvent(Tariff electricity, Tariff gas)
 {
     _eventHub.Publish(new TariffInformationFoundEvent { ElectricityTariff = electricity, GasTariff = gas });
     DisplayTariffRates(electricity, gas);
 }