Exemplo n.º 1
0
 private void TicketSelected(TicketViewModel ticketViewModel)
 {
     try
     {
         PaymentViewModel paymentViewModel = new PaymentViewModel(ticketViewModel);
         PaymentPageView  paymentPageView  = new PaymentPageView();
         paymentPageView.DataContext = (object)paymentViewModel;
         NavigatorHelper.NavigationService.Navigate((object)paymentPageView);
         NavigatorHelper.NavigationService.RemoveBackEntry();
     }
     catch (FormattedDbEntityValidationException ex)
     {
         int num = (int)WPFMessageBox.Show(Resources.ExceptionDbWarning + ex.Message, Resources.ExceptionDbWarningTitle, MessageBoxButton.OK, MessageBoxImage.Asterisk);
         NewTicketViewModel.logger.Warn("Database warning: {0}", ex.Message);
         if (NavigatorHelper.NavigationService == null)
         {
             return;
         }
         NavigatorHelper.NavigationService.Refresh();
     }
 }
Exemplo n.º 2
0
        public PaymentViewModel(TicketViewModel ticket)
        {
            PaymentViewModel.logger.Debug("VIEWMODEL LOADING: PaymentViewModel");
            AuthenticationService.Instance.SuspendService = false;
            this.CurrentTicket            = ticket;
            this.UnitOfWork               = new UnitOfWork();
            this.SelectedItemsCoinPayment = new ObservableCollection <Product>();
            this.TicketProducts           = new ObservableCollection <Product>();
            if (!this.currentTicket.Ticket.Transactions.Any <Transaction>())
            {
                this.CanDeleteOrder = true;
            }
            this.Transactions = new ObservableCollection <TransactionViewModel>();
            foreach (Transaction transaction in (Collection <Transaction>) this.CurrentTicket.Ticket.Transactions)
            {
                this.Transactions.Add(new TransactionViewModel()
                {
                    Transaction    = transaction,
                    NewTransaction = false
                });
            }
            this.NewTransaction = new TransactionViewModel();
            this.NewTransaction.NewTransaction = true;
            CashTransaction cashTransaction = new CashTransaction();

            cashTransaction.PayTime = new DateTime?(DateTime.Now);
            this.NewCashTransaction = cashTransaction;
            CoinTransaction coinTransaction = new CoinTransaction();

            coinTransaction.PayTime = new DateTime?(DateTime.Now);
            this.NewCoinTransaction = coinTransaction;
            FreeTransaction freeTransaction = new FreeTransaction();

            freeTransaction.PayTime = new DateTime?(DateTime.Now);
            this.NewFreeTransaction = freeTransaction;
            NfcTransaction nfcTransaction = new NfcTransaction();

            nfcTransaction.PayTime = new DateTime?(DateTime.Now);
            this.NewNfcTransaction = nfcTransaction;
            if (this.paymentMethodUsed == Transaction.PaymentMethod.Cash)
            {
                this.NewTransaction.Transaction = (Transaction)this.NewCashTransaction;
            }
            else if (this.paymentMethodUsed == Transaction.PaymentMethod.Free)
            {
                this.NewTransaction.Transaction = (Transaction)this.NewFreeTransaction;
            }
            else if (this.paymentMethodUsed == Transaction.PaymentMethod.NFC)
            {
                this.NewTransaction.Transaction = (Transaction)this.NewNfcTransaction;
            }
            else if (this.paymentMethodUsed == Transaction.PaymentMethod.Coin)
            {
                this.NewTransaction.Transaction = (Transaction)this.NewCoinTransaction;
            }
            this.Transactions.Add(this.NewTransaction);
            foreach (TicketLine ticketLine in (Collection <TicketLine>) this.CurrentTicket.Ticket.TicketLines)
            {
                for (int index = 0; index < (int)ticketLine.Amount; ++index)
                {
                    this.TicketProducts.Add(ticketLine.Product);
                }
            }
            foreach (Product ticketProduct in (Collection <Product>) this.TicketProducts)
            {
                this.SelectedItemsCoinPayment.Add(ticketProduct);
            }
            if (this.NewTransaction.Transaction.PaymentMethodUsed == Transaction.PaymentMethod.Cash || this.NewTransaction.Transaction.PaymentMethodUsed == Transaction.PaymentMethod.Free)
            {
                this.NewTransaction.Transaction.Amount = this.CurrentTicket.Ticket.TotalRemaining;
            }
            PaymentViewModel.logger.Debug("VIEWMODEL LOADED: PaymentViewModel");
        }