Esempio n. 1
0
 void ResetToWelcomeScreen()
 {
     lock (lockObj)
     {
         WaffleMachine.Get_Instance().Reset();
         WelcomeScreen ws = new WelcomeScreen();
         ws.Show();
         Close();
     }
 }
Esempio n. 2
0
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            WaffleMachine wm = WaffleMachine.Get_Instance();

            float newWafflePrice, newChocolatePrice;

            if (float.TryParse(txtWafflePrice.Text, out newWafflePrice) && float.TryParse(txtChocolatePrice.Text, out newChocolatePrice))
            {
                wm.WafflePrice    = newWafflePrice;
                wm.ChocolatePrice = newChocolatePrice;
                wm.SavePrices();

                ResetToWelcomeScreen();
            }
            else
            {
                lblError.Visibility = Visibility.Visible;
                txtWafflePrice.Clear();
                txtChocolatePrice.Clear();
            }
        }
        private async void RequestNewOrder(string referenceNum, float amount)
        {
            WaffleApiIntegrator integrator = new WaffleApiIntegrator();
            WaffleMachine       wm         = WaffleMachine.Get_Instance();

            WaffleApiIntegrator.NewOrderResponse response = await integrator.RequestWaffleOrder(wm.GetWaffleCount(), wm.GetChocolateWaffleCount(), referenceNum, amount);

            if (response.statusCode != System.Net.HttpStatusCode.OK || !response.accepted || response.orderId == -1)
            {
                ErrorScreen es = new ErrorScreen();
                es.ShowActivated = true;
                es.Show();
                Close();
            }
            else
            {
                WaitingScreen ws = new WaitingScreen(response.orderId);
                ws.ShowActivated = true;
                ws.Show();
                Close();
            }
        }
        private async void InitiateNewOrder()
        {
            await Task.Delay(10);             //This is to allow time for the UI to be loaded before starting. (Prevents white screen on showing window)

            float      totalToPay      = WaffleMachine.Get_Instance().CalculateTotal();
            Task <int> transactionTask = posHandler.DoTransaction(totalToPay, false);

            int transResult = await transactionTask;

            //testing
            lblDebug.Content += " " + transResult;
            //testing remove True to stop simulating PoS
            if (true || transResult == 0 && posHandler.response != null && posHandler.response.transStatus == PaxPOSECR.POSTransStatus.APPROVED)
            {
                RequestNewOrder(posHandler.referenceNumber.GetLastTransactionRNo(false), totalToPay);
            }
            else
            {
                ErrorScreen es = new ErrorScreen();
                es.ShowActivated = true;
                es.Show();
                Close();
            }
        }