public static int AddTransaction(int item_id, int member_id, decimal amount) { // Get associated Item for item_id and Member for member_id IList<Item> itemList = null; IList<Member> memberList = null; using (GroupDataContext context = new GroupDataContext(ConnectionString)) { IQueryable<Item> query1 = from c in context.Items where c.ID == item_id select c; itemList = query1.ToList(); IQueryable<Member> query2 = from c in context.Members where c.ID == member_id select c; memberList = query2.ToList(); Transaction transaction = new Transaction(); transaction.Amount = amount; transaction.Member = memberList.FirstOrDefault(); transaction.Item = itemList.FirstOrDefault(); context.Transactions.InsertOnSubmit(transaction); context.SubmitChanges(); return transaction.ID; } }
private void OnTransactionRemoved(Transaction transaction) { transaction.Member = null; }
private void OnTransactionRemoved(Transaction transaction) { transaction.Item = null; }
private void OnTransactionAdded(Transaction transaction) { transaction.Member = this; }
private void OnTransactionAdded(Transaction transaction) { transaction.Item = this; }