예제 #1
0
 public void PayOrBorrow(double amount)
 {
     Debt += amount;
     TransactionsList.Add(new Payment(DateTime.Now, amount));
     Notify("Debt");
     //Behøver ikke notify på TransactionsList da den er ObservableCollection
 }
예제 #2
0
        public PaginatedItemsResponse <UserCredits> GetTransactionsPaginated(PaginatedRequest model)
        {
            List <UserCredits> TransactionsList           = null;
            PaginatedItemsResponse <UserCredits> response = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.UserCredits_SelectAll"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@CurrentPage", model.CurrentPage);
                paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage);
                paramCollection.AddWithValue("@Query", model.Query);
            }, map : delegate(IDataReader reader, short set)
            {
                if (set == 0)

                {
                    UserCredits data  = new UserCredits();
                    int startingIndex = 0;   //startingOrdinal

                    data.Id            = reader.GetSafeInt32(startingIndex++);
                    data.UserId        = reader.GetSafeString(startingIndex++);
                    data.Amount        = reader.GetSafeDecimal(startingIndex++);
                    data.TransactionId = reader.GetSafeInt32(startingIndex++);
                    data.JobId         = reader.GetSafeInt32(startingIndex++);
                    data.DateAdded     = reader.GetSafeDateTime(startingIndex++);

                    UserMini User = new UserMini();

                    User.FirstName = reader.GetSafeString(startingIndex++);
                    User.LastName  = reader.GetSafeString(startingIndex++);
                    User.Email     = reader.GetSafeString(startingIndex++);
                    User.Phone     = reader.GetSafeString(startingIndex++);
                    User.Url       = reader.GetSafeString(startingIndex++);

                    data.User = User;

                    if (TransactionsList == null)
                    {
                        TransactionsList = new List <UserCredits>();
                    }

                    TransactionsList.Add(data);
                }
                else if (set == 1)
                {
                    response = new PaginatedItemsResponse <UserCredits>();

                    response.TotalItems = reader.GetSafeInt32(0);
                }
            }

                                    );
            response.Items        = TransactionsList;
            response.CurrentPage  = model.CurrentPage;
            response.ItemsPerPage = model.ItemsPerPage;
            return(response);
        }
예제 #3
0
        // Adiciona a transação à lista de transações.
        private Transactions AddTransactions(int TransactionNumber, TransactionTypeLock LockTransactions)
        {
            Transactions transaction = null;

            if (!TransactionsList.ContainsKey(TransactionNumber))
            {
                transaction = new Transactions(TransactionNumber, LockTransactions);
                TransactionsList.Add(TransactionNumber, transaction);
            }
            else
            {
                transaction = TransactionsList[TransactionNumber];
            }

            return(transaction);
        }