public void Start()
        {
            while (true)
            {
                string option = "";

                Console.WriteLine("---------------------");
                Console.WriteLine("  MANAGER MAIN MENU");
                Console.WriteLine("---------------------");

                Console.WriteLine($"[0]View {location.LocationName} Order History \n[1]Replenish {location.LocationName} Inventory");
                option = Console.ReadLine();

                switch (option)
                {
                case "0":
                    List <Orders> orders = new List <Orders>();
                    orders = orderActions.GetOrdersByLocationId(location.LocationId);


                    Console.WriteLine("------------------------------------------------------------------------------------");
                    Console.WriteLine("        Order Date       |         LoactionId     | CustomerId ");
                    Console.WriteLine("-------------------------------------------------------------------------------------");

                    foreach (Orders order in orders)
                    {
                        Console.WriteLine($"     {order.OrderDate}  |      {order.LocationId}    |    {order.CustomerId}  ");
                    }

                    break;

                case "1":



                    List <Inventory> currInventory = new List <Inventory>();

                    currInventory = inventoryActions.GetInventoryByLocationId(location.LocationId);
                    Console.WriteLine("-------------------------------------------------");
                    Console.WriteLine("InventoryId  | BatID |    Bat Name    | Quantity ");
                    Console.WriteLine("-------------------------------------------------");
                    foreach (Inventory Inventory in currInventory)
                    {
                        BaseballBat bat = batActions.GetBaseballBatById(Inventory.BaseballBatsId);
                        Console.WriteLine($"     {Inventory.InventoryId}       |   {Inventory.BaseballBatsId}    |  {bat.ProductName}  |    {Inventory.Quantity}");
                    }

                    Inventory inventory = new Inventory();
                    int       id;
                    int       replenish;

                    Console.WriteLine("-------------------------------");
                    Console.WriteLine("      UPDATE INVENTORY");
                    Console.WriteLine("-------------------------------");

                    Console.Write("Inventory ID: ");
                    id = int.Parse(Console.ReadLine());

                    inventory = inventoryActions.GetInventoryById(id);

                    Console.Write("Amount to Replenish?: ");
                    replenish = int.Parse(Console.ReadLine());

                    inventory.Quantity += replenish;

                    inventoryActions.UpdateInventory(inventory);
                    Log.Information("Inventory Updated By Manger");

                    Console.WriteLine("Updated Inventory!");

                    break;

                default:
                    Console.WriteLine("Wrong option!");
                    break;
                }
            }
        }
Example #2
0
        public void Start()
        {
            while (true)
            {
                string option = "";
                Log.Information("Entered Main Menu");
                Console.WriteLine("------------------------");
                Console.WriteLine("  CUSTOMER MAIN MENU");
                Console.WriteLine("------------------------");
                Console.WriteLine($"USER: {signedInCustomer.Name} at {currLocation.LocationName}");

                Console.WriteLine("[0]View Inventory/Place Order [1]View Order History");
                option = Console.ReadLine();

                switch (option)
                {
                case "0":
                    List <Inventory> currInventory = new List <Inventory>();

                    currInventory = inventoryActions.GetInventoryByLocationId(currLocation.LocationId);

                    Console.WriteLine("--------------------------------------------");
                    Console.WriteLine(" InventoryId  | BatID | Bat Name | Quantity ");
                    Console.WriteLine("-------------------------------------------");

                    foreach (Inventory Inventory in currInventory)
                    {
                        BaseballBat bat = batActions.GetBaseballBatById(Inventory.BaseballBatsId);

                        Console.WriteLine($"     {Inventory.InventoryId}       |   {Inventory.BaseballBatsId}    |  {bat.ProductName}  |   {Inventory.Quantity}");
                    }

                    Orders    newOrder  = new Orders();
                    Inventory inventory = new Inventory();


                    int invId;
                    int quantity;

                    Console.WriteLine("*Order by Entering The InventoryId and Quantity Desired*");

                    Console.Write("InventoryId: ");
                    invId     = int.Parse(Console.ReadLine());
                    inventory = inventoryActions.GetInventoryById(invId);

                    Console.Write("Quantity: ");
                    quantity = int.Parse(Console.ReadLine());

                    newOrder.OrderDate  = DateTime.Now.ToString();
                    newOrder.LocationId = currLocation.LocationId;
                    newOrder.CustomerId = signedInCustomer.CustomerId;

                    inventory.Quantity -= quantity;

                    try
                    {
                        inventoryActions.UpdateInventory(inventory);
                        orderActions.AddNewOrder(newOrder);
                    }
                    catch (Exception e)
                    {
                        Log.Error($"Exception {e} was thrown");
                    }
                    finally
                    {
                        Log.Information("Finally block reached");
                    }

                    break;

                case "1":
                    List <Orders> orders = new List <Orders>();
                    orders = orderActions.GetOrdersByCustomerId(signedInCustomer.CustomerId);
                    Console.WriteLine("-----------------------------------------------------");
                    Console.WriteLine("        Order Date          | LoactionId | CustomerId ");
                    Console.WriteLine("-----------------------------------------------------");

                    foreach (Orders order in orders)
                    {
                        Console.WriteLine($"     {order.OrderDate}       |   {order.LocationId}    |    {order.CustomerId}  ");
                    }
                    break;

                default:
                    Console.WriteLine("Invalid option");
                    break;
                }
            }
        }