Skip to content

Instantly share code, notes, and snippets.

@vanhouc
Created February 13, 2014 01:36
Show Gist options
  • Save vanhouc/8968123 to your computer and use it in GitHub Desktop.
Save vanhouc/8968123 to your computer and use it in GitHub Desktop.
Prototype of what the TransactionViewModel should look like
using Quagga.DbDomain
namespace Quagga.POS
{
class TransactionViewModel: INotifyPropertyChanged
{
private IDbItemCommands _dbItems;
private IDbTransactionCommands _dbTrans;
public TransactionViewModel(IDbItemCommands dbItems, IDbTransactionCommands dbTrans)
{
_dbItems = dbItems;
_dbTrans = dbTrans;
TransactionID = _dbTrans.getTransactionID();
}
private List<Item> _transactionList;
public List<Item> TransactionList
{
get
{
return _transactionList;
}
set
{
this._transactionList = value;
this.NotifyPropertyChanged("TransactionList");
}
}
private string _transactionID;
public string TransactionID
{
get
{
return _transactionID;
}
protected set
{
this._transactionID = value;
this.NotifyPropertyChanged("TransactionID");
}
}
public AddItemtoTransaction(string UPC)
{
Item itemToAdd = _dbItems.getItemByUPC(UPC);
if (itemToAdd == null)
{
throw new ItemNotFoundException("Item " + UPC + "not found in database");
}
TransactionList.add(itemToAdd);
}
public RingOutTransaction()
{
if (TransactionList.count < 1)
{
throw new ArgumentException("Must have at least 1 item for a transaction");
}
_dbTrans.processTransaction(TransactionID, TransactionList);
TransactionList.Clear();
TransactionID = _dbTrans.getTransactionID();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment