Example #1
0
        private static void AddTransaction(int customerId, decimal amount, string description, PaymentType paymentType, TransactionType transactionType, bool isCustomer)
        {
            int suppId = -1;
            int custId = -1;
            if (isCustomer)
            {
                custId = customerId;
            }
            else
            {
                suppId = customerId;
            }
            using (var workspace = WorkspaceFactory.Create())
            {
                if (transactionType == TransactionType.Income || transactionType == TransactionType.Expense)
                {
                    var c = new CashTransaction
                    {
                        Amount = amount,
                        Date = DateTime.Now,
                        Name = description,
                        PaymentType = (int)paymentType,
                        TransactionType = (int)transactionType,
                        UserId = AppServices.CurrentLoggedInUser.Id,
                        CustomerId = custId,
                        SupplierId = suppId
                    };
                    workspace.Add(c);
                }
                else
                {
                    var c = new AccountTransaction
                    {
                        Amount = amount,
                        Date = DateTime.Now,
                        Name = description,
                        TransactionType = (int)transactionType,
                        UserId = AppServices.CurrentLoggedInUser.Id,
                        CustomerId = custId,
                        SupplierId = suppId
                    };
                    workspace.Add(c);
                }

                workspace.CommitChanges();
            }
        }
 public CashTransactionViewModel(CashTransaction transaction)
 {
     Model = transaction;
 }