Exemple #1
0
        public void CheckOutItems()
        {
            Cart            cart  = cartServices.GetCartByCustId(customer.Id);
            List <CartItem> items = cartItemServices.GetAllCartItemsByCartId(cart.Id);
            Orders          order = new Orders();
            double          total = 0;

            order.CustomersId = customer.Id;
            order.LocationId  = customer.LocationId;
            DateTime dateOfOrder = order.dateOfOrder = DateTime.Now;

            orderServices.AddOrder(order);
            Orders orderToProcess = orderServices.GetOrderByDate(dateOfOrder);

            Console.WriteLine("You imaginary order has been placed. You will revieve it never. \n");
            foreach (CartItem item in items)
            {
                lineItem lineItem = new lineItem();
                Sticks   stick    = productServices.GetProductByStickId(item.stickId);
                lineItem.orderId  = orderToProcess.Id;
                lineItem.stickId  = item.stickId;
                lineItem.price    = stick.Price;
                lineItem.quantity = item.quantity;
                total            += (stick.Price * item.quantity);
                lineItemServices.AddLineItem(lineItem);
                cartItemServices.DeleteCartItem(item);
                Inventory inventory = inventoryServices.GetItemByLocIdStickId(customer.LocationId, stick.Id);
                inventory.quantity -= item.quantity;
            }
            order.TotalPrice = total;
            orderServices.UpdateOrder(orderToProcess);
            Console.WriteLine($"\nYour total was: ${order.TotalPrice}");
        }
Exemple #2
0
        public void updateStock(int stickId)
        {
            Selectedinventory = inventoryServices.GetItemByLocIdStickId(selectedLoc, stickId);
            Console.WriteLine("How much of this item would you like to add to the inventory?");
            int toAdd = Int32.Parse(Console.ReadLine());

            Selectedinventory.quantity = toAdd + Selectedinventory.quantity;
            inventoryServices.UpdateInventory(Selectedinventory);
            Console.WriteLine("The stock of this item has been updated!");
        }
Exemple #3
0
        public void Start()
        {
            do
            {
                Inventory selected = inventoryServices.GetItemByLocIdStickId(customer.LocationId, stick.Id);
                inventoryQuantity = selected.quantity;

                Console.WriteLine("The item you have selected: ");
                Console.WriteLine($"{stick.description} \t${stick.Price}");

                Console.WriteLine("Would you like to add this item to cart?");
                Console.WriteLine("[0] No \n[1] Yes");
                custInput = Console.ReadLine();
                switch (custInput)
                {
                case "0":
                    break;

                case "1":
                    int quantity;

                    do
                    {
                        Console.WriteLine("How many would you like of this item?");
                        quantity = Int32.Parse(Console.ReadLine());
                    } while (ValidInvalidServices.InvalidQuanityOfItems(inventoryQuantity, quantity) == false);
                    CartItem ci       = new CartItem();
                    Cart     custCart = cartServices.GetCartByCustId(customer.Id);
                    ci.cartId   = custCart.Id;
                    ci.stickId  = stick.Id;
                    ci.quantity = quantity;
                    cartItemServices.AddCartItem(ci);
                    Console.WriteLine("Your item has been added to your cart");
                    break;

                default:
                    ValidInvalidServices.InvalidInput();
                    break;
                }
            } while (!(custInput.Equals("1")));
        }