public CloseOrderMenu(Customer customer, OrderManager orderManager, ProductManager productManager, PaymentTypeManager paymentTypeManager)
 {
     _customer           = customer;
     _orderManager       = orderManager;
     _productManager     = productManager;
     _paymentTypeManager = paymentTypeManager;
 }
Exemplo n.º 2
0
        public ActiveCustomerManager_Should()
        {
            // path to the environment variable on the users computer
            string testPath = System.Environment.GetEnvironmentVariable("BANGAZON_CLI_APP_DB_TEST");

            // Instantiating a new DatabaseInterface and passing in the string path
            _db = new DatabaseInterface(testPath);

            // Initializing class instances to access class methods. Also these all create their respective tables in database, which wil be erased when tests are complete.
            _customerManager       = new Managers.CustomerManager(_db);
            _activeCustomerManager = new Managers.ActiveCustomerManager(_customerManager);
            _productManager        = new ProductManager(_db);
            _orderManager          = new OrderManager(_db);
            _paymentTypeManager    = new PaymentTypeManager(_db);

            // Initializing a mock customer for testing purposes
            _customer               = new Models.Customer();
            _customer.Id            = 1;
            _customer.Name          = "Dre Man";
            _customer.StreetAddress = "123 Somewhere";
            _customer.City          = "Nashville";
            _customer.State         = "TN";
            _customer.PostalCode    = "323232";
            _customer.PhoneNumber   = "9876543";
        }
 // Class constructor. Takes
 public PaymentTypeMenu(PaymentType paymentType, PaymentTypeManager paymentTypeManager, Customer activeCustomer)
 {
     _activeCustormerId  = activeCustomer.Id;
     _activeCustomerName = activeCustomer.Name;
     _paymentType        = paymentType;
     _paymentTypeManager = paymentTypeManager;
 }
        // Creates a payment type manager and connection with the database..

        public PaymentTypeManagerShould()
        {
            _db  = new dbUtilities("BANGAZONCLI_TEST_DB");
            _ptm = new PaymentTypeManager(_db);
            _db.CheckPaymentType();
            _cm = new CustomerManager(_db);
        }
        public void GetAllPaymentType_Should()
        {
            PaymentTypeManager manager = new PaymentTypeManager("BangazonTestDB");

            manager.AddPaymentType(_paymenttype);
            List <PaymentType> paymentList = manager.GetAllPaymentTypes();

            Assert.Contains(_paymenttype, paymentList);
        }
        // Instantiate the Test
        public CustomerManager_Should()
        {
            string testPath = System.Environment.GetEnvironmentVariable("BANGAZON_CLI_APP_DB_TEST");

            _db = new DatabaseInterface(testPath);
            // initialize managers to create db tables and use later in tests
            _customerManager    = new CustomerManager(_db);
            _productManager     = new ProductManager(_db);
            _orderManager       = new OrderManager(_db);
            _paymentTypeManager = new PaymentTypeManager(_db);
        }
Exemplo n.º 7
0
        public PaymentManagerShould()
        {
            string prodPath = System.Environment.GetEnvironmentVariable("BANGAZON_TEST_DB");
            // Create connection to test database and capture in DatabaseConnection variable db
            DatabaseConnection db = new DatabaseConnection(prodPath);

            // Set the private DatabaseConnection variable of _db to equal the DatabaseConnection of db
            _db = db;
            // Ensure there is a database with tables at the end of the test database connection
            DatabaseStartup databaseStartup = new DatabaseStartup(_db);

            _ptm = new PaymentTypeManager(_db);
        }
        public void AddPaymentTypeStringBuilder(PaymentTypeManager SB)
        {
            PaymentType paymentType = new PaymentType();
            Customer    customer    = new Customer();

            Console.WriteLine("Enter payment method:");
            Console.Write("> ");
            paymentType.PaymentMethod = Console.ReadLine();
            Console.WriteLine("Enter account number:");
            Console.Write("> ");
            paymentType.AccountNumber = Int32.Parse(Console.ReadLine());
            SB.AddPaymentType(paymentType);
            Menus.MainMenu();
        }
Exemplo n.º 9
0
 public UnitOfWork(ApplicationDbContext context)
 {
     this.context    = context;
     Products        = new ProductManager(context);
     Categories      = new CategoryManager(context);
     Images          = new ImageManager(context);
     Orders          = new OrderManager(context);
     Payments        = new PaymentTypeManager(context);
     Tags            = new TagManager(context);
     CartItems       = new CartItemManager(context);
     ProductPayments = new ProductPaymentsManager(context);
     ProductTag      = new ProductTagsManager(context);
     OrderProduct    = new OrderProductManager(context);
 }
        public PaymentTypeManager_Should()
        {
            // Establishing the path to the database
            string testPath = System.Environment.GetEnvironmentVariable("BANGAZON_CLI_APP_DB_TEST");

            // Initializing an instance of the DatabaseInterface
            _db = new DatabaseInterface(testPath);

            // By initializing these managers, all of the tables are created
            _paymentTypeManager = new PaymentTypeManager(_db);
            _custManager        = new CustomerManager(_db);
            _prodManager        = new ProductManager(_db);
            _orderManager       = new OrderManager(_db);
        }
Exemplo n.º 11
0
        public void AddPaymentTypeToOrderShould()
        {
            CustomerManager    _customerManager = new CustomerManager(_db);
            ActiveCustomer     _activeManager   = new ActiveCustomer();
            PaymentTypeManager _paymentManager  = new PaymentTypeManager(_db);
            var newCustomerId = _customerManager.AddCustomer(new Customer("Bob", "Some Street", "City", "TN", 12345, "5555555555"));

            _activeManager.setActiveCustomerId(newCustomerId);
            var newPayment       = _paymentManager.CreatePaymentType(new PaymentType(newCustomerId, "Merit", "1"));
            var newOrderId       = _orderManager.CreateOrder();
            var orderWithPayment = _orderManager.AddPaymentTypeToOrder(newPayment); //the parameter passed is the id of the payment type

            Assert.True(orderWithPayment);
        }
Exemplo n.º 12
0
        //Produces the actual menu the user will interact with. Utilizes the ordermanager, product manager, and paymenttype manager to get all relevant info to complete a customer's order.
        public static void CompleteOrderMenu(OrderManager om, ProductManager pm, PaymentTypeManager ptm)
        {
            Order activeOrder = om.GetActiveCustomerOrder(CustomerManager.currentCustomer.customerID);

            if (activeOrder.orderID == 0)
            {
                Console.WriteLine("Please add some products to your order first. Press any key to return to main menu.");
                Console.ReadKey();
                return;
            }
            activeOrder.products = pm.GetProductsOnOrder(activeOrder.orderID);
            double orderTotal     = activeOrder.products.Sum(product => product.price);
            string completeChoice = showCompletionOption(orderTotal);

            while (completeChoice != "Y" && completeChoice != "y" && completeChoice != "N" && completeChoice != "n")
            {
                Console.WriteLine(completeChoice);
                Console.WriteLine("Sorry, I didn't understand your input.");
                completeChoice = showCompletionOption(orderTotal);
            }
            if (completeChoice == "N" || completeChoice == "n")
            {
                Console.WriteLine("Order not completed. Press any key to return to main menu.");
                Console.ReadKey();
                return;
            }
            List <PaymentType> customersPaymentTypes = ptm.GetCustomersPaymentTypes(CustomerManager.currentCustomer.customerID);
            int ptindex = 1;

            Console.WriteLine("Please select a previously stored payment option:");
            foreach (PaymentType paymenttype in customersPaymentTypes)
            {
                Console.WriteLine($"{ptindex}. {paymenttype.name}");
                ptindex++;
            }
            Console.WriteLine("> ");
            int paymentChoiceIndex = int.Parse(Console.ReadLine());

            paymentChoiceIndex       -= 1;
            activeOrder.paymentTypeID = customersPaymentTypes[paymentChoiceIndex].paymentTypeID;
            om.CompleteOrder(activeOrder);
            Console.WriteLine("You order is now complete. Press any key to return to the main menu.");
            Console.ReadKey();
            return;
        }
        public void AddPaymentType_Should()
        {
            CustomerManager    custManager = new CustomerManager("BangazonTestDB");
            PaymentTypeManager manager     = new PaymentTypeManager("BangazonTestDB");
            Customer           newCust     = custManager.Add(_customer);

            custManager.ActivateCustomer(newCust.Id);

            PaymentType _paymentType2 = new PaymentType(
                "AMEX",
                "172635",
                custManager.ActiveCustomer.Id
                );

            PaymentType newPaymentType = manager.AddPaymentType(_paymentType2);

            Assert.Equal("AMEX", newPaymentType.Name);
            Assert.Equal(custManager.ActiveCustomer.Id, newPaymentType.CustomerId);
        }
        // instatiate the test
        public ProductManager_Should()
        {
            string testPath = System.Environment.GetEnvironmentVariable("BANGAZON_CLI_APP_DB_TEST");

            _db = new DatabaseInterface(testPath);
            // initialize managers to create db tables and use later in tests
            _customerManager    = new CustomerManager(_db);
            _productManager     = new ProductManager(_db);
            _orderManager       = new OrderManager(_db);
            _paymentTypeManager = new PaymentTypeManager(_db);

            // create customer
            _customer               = new Customer();
            _customer.Id            = 1;
            _customer.Name          = "K Bird";
            _customer.StreetAddress = "123 Somewhere";
            _customer.City          = "Nashville";
            _customer.State         = "TN";
            _customer.PostalCode    = "323232";
            _customer.PhoneNumber   = "9876543";
        }
        // constructor for unit test
        public OrderManagerShould()
        {
            // create database path
            string testPath = System.Environment.GetEnvironmentVariable("BANGAZON_CLI_APP_DB_TEST");

            _db = new DatabaseInterface(testPath);

            // initialize managers to create db tables and use later in tests
            _orderManager       = new OrderManager(_db);
            _productManager     = new ProductManager(_db);
            _customerManager    = new CustomerManager(_db);
            _paymentTypeManager = new PaymentTypeManager(_db);

            // create a new customer instance
            _customer = new Customer();
            // properties added to new customer
            _customer.Id            = 1;
            _customer.Name          = "G Lawrence";
            _customer.StreetAddress = "123 Somewhere";
            _customer.City          = "Nashville";
            _customer.State         = "TN";
            _customer.PostalCode    = "37206";
            _customer.PhoneNumber   = "8018959001";

            // create a new order instance
            _testOrder = new Order();
            // create a new product instance
            _testProduct = new Product()
            {
                CustomerId  = _customer.Id,
                Name        = "Bicycle",
                Price       = 55.25,
                Description = "Awesome bike",
                Quantity    = 1
            };
        }
Exemplo n.º 16
0
        /*
         *  Class: AddPayment
         *  Purpose: This class will allow users to enter payment type information into the command line. The user input will be addd to the database.
         *  Author: Joey
         */
        public static void AddPay(PaymentTypeManager payment)
        {
            Console.Clear();
            //Checks if there's an active customer
            if (CustomerManager.activeCustomer == 0)
            {
                Console.WriteLine("* Please choose an active customer before continuing *");
                Console.WriteLine("* Press 'ENTER' to return to the main menu *");
                Console.ReadLine();
            }
            else
            {
                // Enter in the necessary info to create a product
                Console.WriteLine("Enter payment type(e.g. AmEx, Visa, Checking)");
                Console.Write(">");
                string name = Console.ReadLine();
                Console.Clear();
                Console.WriteLine("Enter account number");
                Console.Write(">");
                string accountNumber = Console.ReadLine();

                // Builds/Sends a new payment type, where it gets added to the PaymentManager
                int payType = payment.AddPayment(new PaymentType()
                {
                    Name          = name,
                    CustomerId    = CustomerManager.activeCustomer,
                    AccountNumber = accountNumber
                }

                                                 );

                Console.WriteLine($"Payment Type: {payType} has been added to the menu!");
                Console.WriteLine("* Press 'ENTER' to return to the main menu *");
                Console.ReadLine();
            }
        }
 public PaymentTypeShould()
 {
     _db = new DatabaseInterface("BANGAZONCLI_TEST_DB");
     _pt = new PaymentTypeManager(_db);
     _db.CheckPaymentTypeTable();
 }
Exemplo n.º 18
0
 public PaymentTypeManagerShould()
 {
     _db      = new DatabaseInterface("BANGAZON_CLI_DB");
     _manager = new PaymentTypeManager(_db);
     _db.RunCheckForTable();
 }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            // Initalize the interface
            string            prodPath = System.Environment.GetEnvironmentVariable("BANGAZON_CLI_APP_DB");
            DatabaseInterface db       = new DatabaseInterface(prodPath);

            // Initialize the Manager objects
            CustomerManager       customerManager       = new CustomerManager(db);
            ActiveCustomerManager activeCustomerManager = new ActiveCustomerManager(customerManager);
            ProductManager        productManager        = new Managers.ProductManager(db);
            OrderManager          orderManager          = new OrderManager(db);
            PaymentTypeManager    paymentTypeManager    = new PaymentTypeManager(db);

            Customer activeCustomer = new Customer();

            int choice;

            // When the user enters the system show the main menu
            do
            {
                choice = MainMenu.Show(activeCustomer);

                switch (choice)
                {
                // Add customer
                case 1:
                {
                    AddCustomerMenu customerMenu = new AddCustomerMenu(new Customer(), customerManager);
                    customerMenu.Show();
                    break;
                }

                /*
                 *  List the customers and allow the user to select a customer based on the
                 *  position in the list
                 */
                case 2:
                {
                    ActiveCustomerMenu activeCustomerMenu = new ActiveCustomerMenu(customerManager);
                    int customerId = activeCustomerMenu.Show();
                    activeCustomer = activeCustomerManager.SetActiveCustomer(customerId);
                    break;
                }

                /*
                 *  Add a new payment type for a customer
                 */

                case 3:
                {
                    PaymentTypeMenu addPaymentTypeMenu = new PaymentTypeMenu(new PaymentType(), paymentTypeManager, activeCustomer);
                    addPaymentTypeMenu.Show();
                    break;
                }

                /*
                 *  Add product to active customer
                 */
                case 4:
                {
                    AddProductMenu addProductMenu = new AddProductMenu(activeCustomer, new Product(), productManager);
                    addProductMenu.Show();
                    break;
                }

                /*
                 *  Update an active customer's product
                 */
                case 5:
                {
                    UpdateProductMenu updateProductMenu = new UpdateProductMenu(activeCustomer, productManager);
                    updateProductMenu.Show();
                    break;
                }



                /*
                 *  List the active customer's product(s)
                 *  The user cannot delete products that are on active orders
                 */
                case 6:
                {
                    DeleteActiveCustomerProductsMenu menu = new DeleteActiveCustomerProductsMenu(activeCustomer, productManager);
                    menu.Show();
                    break;
                }

                /*
                 *  Lists all products to allow user to choose one to add to their order. When product is chosen, the product is added to the active customer's order
                 */

                case 7:
                {
                    AddProductToCartMenu addProductToCartMenu = new AddProductToCartMenu(activeCustomer, orderManager, productManager);
                    addProductToCartMenu.Show();
                    break;
                }

                /*
                 *  Allow user to complete order.
                 *  Checks to make sure active customer's order contains products
                 *  If products exist on order, displays the total order amount in dollars.
                 *  Allows user to Add Payment type to their order.
                 */

                case 8: {
                    CloseOrderMenu closeOrderMenu = new CloseOrderMenu(activeCustomer, orderManager, productManager, paymentTypeManager);
                    closeOrderMenu.Show();
                    break;
                }


                default:
                {
                    break;
                }
                }
            } while (choice != 10);
        }
 public AddPaymentTypeStringBuilderManagerShould()
 {
     _db = new DatabaseInterface("BANGAZONCLI_DB");
     _db.CheckPaymentTypeTable();
     _kathy = new PaymentTypeManager(_db);
 }
 public PaymentTypeManagerShould()
 {
     _paymentManager = new PaymentTypeManager();
 }