Exemplo n.º 1
0
        /// <summary>
        /// Takes a user and an amount and returns the transaction
        /// </summary>
        /// <param name="user"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public InsertCashTransaction AddCreditsToAccount(User user, int amount)
        {
            Transaction transaction = new InsertCashTransaction(_logFile.LinesInFile + 1, user, amount);

            ExecuteTransaction(transaction);

            return(transaction as InsertCashTransaction);
        }
Exemplo n.º 2
0
        // Inserting cash to a users account
        public InsertCashTransaction AddCreditsToAccount(User user, decimal amount)
        {
            InsertCashTransaction insertCashTransaction = new InsertCashTransaction(user, DateTime.Now, amount);

            ExecuteTransaction(insertCashTransaction);
            _writingfiles.WritingUsersFile(insertCashTransaction);
            user.NumberOfTransactions++;
            return(insertCashTransaction);
        }
        public int AddCreditsToAccount(User user, float amount)
        {
            InsertCashTransaction insertCashTransaction = new InsertCashTransaction(user, amount);

            TrackTransaction(insertCashTransaction);
            Logger.WriteMessage(insertCashTransaction.ToString());

            return(0);
        }
Exemplo n.º 4
0
        public InsertCashTransaction AddCreditsToAccount(User user, int amount)
        {
            InsertCashTransaction insCashTrans = new InsertCashTransaction(user, amount);

            _transactionList.Add(insCashTrans);
            LogTransaction(insCashTrans.ToString());

            return(insCashTrans);
        }
Exemplo n.º 5
0
        public StregsystemController(IStregsystemUI ui)
        {
            UI             = (StregsystemCLI)ui;
            _adminCommands = new Dictionary <string, Action <dynamic, dynamic> > {
                { "?", (x, y) => UI.DisplayHelp() },

                { ":q", (x, y) => UI.Close() },
                { ":quit", (x, y) => UI.Close() },
                {
                    ":activate",
                    (x, y) => {
                        Product.Find(int.Parse(x)).Activate();
                        UI.DisplayActivation(int.Parse(x), true);
                    }
                },
                {
                    ":deactivate",
                    (x, y) => {
                        Product.Find(int.Parse(x)).Deactivate();
                        UI.DisplayActivation(int.Parse(x), false);
                    }
                },
                {
                    ":crediton",
                    (x, y) => {
                        Product.Find(x).CanBeBoughtOnCredit = true;
                        UI.DisplayCreditChange(x, false);
                    }
                },
                {
                    ":creditoff",
                    (x, y) => {
                        Product.Find(x).CanBeBoughtOnCredit = false;
                        UI.DisplayCreditChange(x, false);
                    }
                },
                {
                    ":addcredits",
                    (x, y) => {
                        User u           = User.FindBy("Username", x);
                        var  transaction = new InsertCashTransaction(u, decimal.Parse(y));
                        transaction.Execute();
                        UI.DisplayAddedCreditsToUser(User.FindBy("Username", x), decimal.Parse(y));
                    }
                }
            };
        }
Exemplo n.º 6
0
        private void InsertCashTransaction(string username, int amount)
        {
            User user = _stregsystem.GetUserByUsername(username);

            if (user != null)
            {
                if (amount > 0)
                {
                    InsertCashTransaction iCT = _stregsystem.AddCreditsToAccount(user, amount);
                    _ui.DisplayTransaction(iCT);
                }
                else
                {
                    _ui.DisplayGeneralError("Cannot insert negative cash.");
                }
            }
        }
Exemplo n.º 7
0
        public InsertCashTransaction AddCreditsToAccount(User user, decimal amount, List <User> UserList)
        {
            InsertCashTransaction Transaction = new InsertCashTransaction(user, DateTime.Now, amount, UserList);

            return(Transaction);
        }