Пример #1
0
 /// <summary>
 /// Constructor with sales database
 /// </summary>
 /// <param name="sdb"></param>
 public ConsoleGUI(SalesDatabase sdb)
 {
     _sdb = sdb;
 }
Пример #2
0
 /// <summary>
 /// Initalizes cashier model
 /// </summary>
 /// <param name="db">An instance of the salesdatabase</param>
 public CashierModel(SalesDatabase db)
 {
     _salesDatabase = db;
 }
Пример #3
0
        /// <summary>
        /// Runs the ConsoleGUI
        /// </summary>
        /// <param name="db">the sales database</param>
        static void ConsoleGUI(SalesDatabase db)
        {
            Console.Clear();

            Console.WriteLine("\n  1) Create Sale Transaction \n");
            Console.WriteLine("  2) Return Item \n");
            Console.WriteLine("  3) Rebate Request \n");
            Console.WriteLine("  4) Generate Rebate \n");
            Console.WriteLine("  5) Quit \n");
            Console.WriteLine("------------------");

            char a = '0';

            RebateModel      rm = null;
            RebateController rc = null;

            while (a != '5')
            {
                Console.Write("\n\nSelect an option: ");
                a = Console.ReadLine()[0];

                switch (a)
                {
                case '1':
                    Console.Write("\nEnter the date(MM/DD): ");
                    DateTime date           = new DateTime();
                    bool     successfulDate = false;

                    while (!successfulDate)
                    {
                        try
                        {
                            date           = Convert.ToDateTime(Console.ReadLine());
                            successfulDate = true;
                        }
                        catch (Exception err)
                        {
                            Console.WriteLine("Enter a valid date.");
                        }
                    }
                    CashierModel      cm    = new CashierModel(db);
                    CashierController cc    = new CashierController(cm);
                    ConsoleGUI        sales = new ConsoleGUI(cm, date, cc.handleRemoveItem, cc.handleAddItem,
                                                             cc.handleCompleteSale, cc.handleCreateSale);
                    sales.ListItems();
                    sales.AddItem();
                    break;

                case '2':
                    CustomerServiceModel      csm = new CustomerServiceModel(db);
                    CustomerServiceController csc = new CustomerServiceController(csm);
                    ConsoleGUI sc = new ConsoleGUI(csm, csc.HandleGetSale, csc.HandleReturnItem);
                    sc.ReturnItem();
                    break;

                case '3':
                    rm = new RebateModel(db);
                    rc = new RebateController(rm);
                    ConsoleGUI rebate = new ConsoleGUI(rm, rc.handleGenerateRebate, rc.handleEnterRebate);
                    rebate.Rebate();
                    break;

                case '4':
                    try
                    {
                        ConsoleGUI grebate = new ConsoleGUI(rm, rc.handleGenerateRebate, rc.handleEnterRebate);
                        grebate.GenerateRebate();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Request Rebates first!");
                    }
                    break;

                case '5':
                    break;

                default:
                    Console.WriteLine("Enter a number 1-5 \n");
                    a = Console.ReadLine()[0];
                    break;
                }
            }
        }
Пример #4
0
 /// <summary>
 /// The constructor for the CustomerServiceModel.
 /// </summary>
 /// <param name="sd">The current working SalesDatabase.</param>
 public CustomerServiceModel(SalesDatabase sd)
 {
     this.sd = sd;
     state   = CustomerServiceState.Initial;
 }
Пример #5
0
 /// <summary>
 /// Consturcts the RebateModel
 /// </summary>
 /// <param name="sd">The current in use SalesDatabase</param>
 public RebateModel(SalesDatabase sd)
 {
     _salesDatabase = sd;
     State          = RebateModelState.Initial;
     _rebates       = new List <Sale>();
 }