public PaymentViewModel() { PaymentViewModel.logger.Debug("VIEWMODEL LOADING: PaymentViewModel"); AuthenticationService.Instance.SuspendService = false; this.CurrentTicket = new TicketViewModel(); this.UnitOfWork = new UnitOfWork(); this.SelectedItemsCoinPayment = new ObservableCollection <Product>(); this.TicketProducts = new ObservableCollection <Product>(); this.Transactions = new ObservableCollection <TransactionViewModel>(); 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); PaymentViewModel.logger.Debug("VIEWMODEL LOADED: PaymentViewModel"); }
private void OnPaymentMethodChanged(Transaction.PaymentMethod paymentMethod) { this.Transactions.Remove(this.NewTransaction); this.NewTransaction = new TransactionViewModel(); this.NewTransaction.NewTransaction = true; CashTransaction cashTransaction = new CashTransaction(); cashTransaction.PayTime = new DateTime?(DateTime.Now); cashTransaction.PaymentMethodUsed = paymentMethod; this.NewCashTransaction = cashTransaction; CoinTransaction coinTransaction = new CoinTransaction(); coinTransaction.PayTime = new DateTime?(DateTime.Now); coinTransaction.PaymentMethodUsed = paymentMethod; this.NewCoinTransaction = coinTransaction; FreeTransaction freeTransaction = new FreeTransaction(); freeTransaction.PayTime = new DateTime?(DateTime.Now); freeTransaction.PaymentMethodUsed = paymentMethod; this.NewFreeTransaction = freeTransaction; NfcTransaction nfcTransaction = new NfcTransaction(); nfcTransaction.PayTime = new DateTime?(DateTime.Now); nfcTransaction.PaymentMethodUsed = paymentMethod; this.NewNfcTransaction = nfcTransaction; if (this.paymentMethodUsed == Transaction.PaymentMethod.Cash) { this.NewTransaction.Transaction = (Transaction)this.NewCashTransaction; this.NewTransaction.Transaction.Amount = this.CurrentTicket.Ticket.TotalRemaining; } else if (this.paymentMethodUsed == Transaction.PaymentMethod.Free) { this.NewTransaction.Transaction = (Transaction)this.NewFreeTransaction; this.NewTransaction.Transaction.Amount = this.CurrentTicket.Ticket.TotalRemaining; } 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); }
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"); }