예제 #1
0
        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;
            }
        }
예제 #2
0
 private void OnTransactionRemoved(Transaction transaction)
 {
     transaction.Member = null;
 }
예제 #3
0
 private void OnTransactionRemoved(Transaction transaction)
 {
     transaction.Item = null;
 }
예제 #4
0
 private void OnTransactionAdded(Transaction transaction)
 {
     transaction.Member = this;
 }
예제 #5
0
 private void OnTransactionAdded(Transaction transaction)
 {
     transaction.Item = this;
 }