Ejemplo n.º 1
0
        public void start()
        {
            List <CartItem> items = cartitemtask.GetAllCartItems(1);

            do
            {
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("[1] View Items in Cart");
                Console.WriteLine("[2] Check Out");
                Console.WriteLine("[3] Go Back");
                userInput = Console.ReadLine();

                switch (userInput)
                {
                case "1":

                    foreach (CartItem Item in items)
                    {
                        int     id   = Item.ProductId;
                        Product prod = producttask.GetProduct(id);
                        Console.WriteLine("ItemName: " + prod.Name);
                        Console.WriteLine("Quantity: " + Item.Quantity);
                    }
                    break;

                case "2":

                    Cart    cart  = carttask.GetCart(1);
                    Order   order = new Order();
                    decimal total = 0;
                    order.CustomerId = 1;
                    DateTime orderDate = order.Date = DateTime.Now;
                    ordertask.AddOrder(order);
                    Order neworder = ordertask.GetOrderByDate(orderDate);
                    Console.WriteLine("Thank you for placing an order!");


                    foreach (CartItem cartitem in items)
                    {
                        Product product = producttask.GetProduct(cartitem.ProductId);

                        OrderItem orderitem = new OrderItem();
                        orderitem.ProductId = cartitem.ProductId;
                        orderitem.Quantity  = cartitem.Quantity;
                        orderitem.OrderId   = neworder.OrderId;

                        decimal itemprice = product.Cost;
                        total += (itemprice * cartitem.Quantity);

                        orderitemtask.AddOrderItem(orderitem);
                        cartitemtask.DeleteCartItem(cartitem);
                    }
                    neworder.Totalprice = total;
                    ordertask.UpdateOrder(neworder);
                    break;
                }
            }while (!userInput.Equals("3"));
        }
Ejemplo n.º 2
0
        public void start()
        {
            Console.WriteLine("Select a location!");
            LocationTask    locationtask = new LocationTask(repo);
            List <Location> Location     = locationtask.GetAllLocations();
            CartTask        cartTask     = new CartTask(repo);
            CartItemTask    cartitemtask = new CartItemTask(repo);
            ProductTask     producttask  = new ProductTask(repo);
            Cart            cart         = cartTask.GetCartByCustomer(1);

            count = 1;
            foreach (Location singleLocation in Location)
            {
                Console.WriteLine("[" + count + "]");
                Console.WriteLine(singleLocation.Name);
                count++;
            }
            userInput = Console.ReadLine();
            int           Locationid    = Int32.Parse(userInput);
            InventoryTask inventorytask = new InventoryTask(repo);

            Console.WriteLine("Getting items...");
            List <Inventory> Items        = inventorytask.GetInventoryByLocation(Locationid);
            string           continueloop = "y";

            while (continueloop == "y")
            {
                foreach (Inventory Item in Items)
                {
                    int     id   = Item.ProductId;
                    Product prod = producttask.GetProduct(id);
                    Console.WriteLine("Product ID: " + id);
                    Console.WriteLine("Item Name: " + prod.Name);
                    Console.WriteLine("Cost: " + prod.Cost);
                    Console.WriteLine("Quantity: " + Item.Quantity);
                    Console.WriteLine(" ");
                }

                Console.WriteLine("Select a product (By ID!)");
                userInput = Console.ReadLine();
                Product  chosenproduct = producttask.GetProduct(Int32.Parse(userInput));
                CartItem cartitem      = new CartItem();
                cartitem.ProductId = Int32.Parse(userInput);
                Console.WriteLine("How many do you want to buy?");
                string input = Console.ReadLine();
                cartitem.CartId   = 1;
                cartitem.Quantity = Int32.Parse(input);
                cartitemtask.UpdateCartItem(cartitem);
                Console.WriteLine("Item has been added!");
                Console.WriteLine("Keep adding to cart? (y/n)");
                continueloop = Console.ReadLine();
            }
        }
Ejemplo n.º 3
0
        public async Task ThenItShouldBeAppearInTheListOfProducts()
        {
            var productId = ScenarioContext.Get <int>("product-Id");
            var command   = ScenarioContext.Get <CreateProductCommand>("product");

            var product = await _productTask.GetProduct(productId);

            product.Title.Should().Be(command.Title);
            product.EnglishTitle.Should().Be(command.EnglishTitle);
            product.BrandId.Should().Be(command.BrandId);
            product.Description.Should().Be(command.Description);
            product.AtAGlance.Should().Be(command.AtAGlance);
            product.IsActive.Should().Be(command.IsActive);
        }
Ejemplo n.º 4
0
        public void start()
        {
            do
            {
                Console.WriteLine("Select a location!");
                List <Location> Location = locationtask.GetAllLocations();
                count = 1;
                foreach (Location singlelocation in Location)
                {
                    Console.WriteLine("[" + count + "]");
                    Console.WriteLine(singlelocation.Name);
                    count++;
                }
                locationstring = Console.ReadLine();
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("[1] Check Inventory");
                Console.WriteLine("[2] Replenish Inventory");
                Console.WriteLine("[3] Go Back");
                userInput = Console.ReadLine();
                int Locationid         = Int32.Parse(locationstring);
                List <Inventory> Items = inventorytask.GetInventoryByLocation(Locationid);
                switch (userInput)
                {
                case "1":
                    //Pulls up inventory for selected location

                    Console.WriteLine("Getting items...");
                    foreach (Inventory Item in Items)
                    {
                        int     id   = Item.ProductId;
                        Product prod = producttask.GetProduct(id);
                        Console.WriteLine("Product ID: " + id);
                        Console.WriteLine("Item Name: " + prod.Name);
                        Console.WriteLine("Quantity: " + Item.Quantity);
                        Console.WriteLine(" ");
                    }
                    break;

                case "2":
                    //Replenishes inventory
                    Console.WriteLine("Getting items...");
                    foreach (Inventory Item in Items)
                    {
                        int     id   = Item.ProductId;
                        Product prod = producttask.GetProduct(id);
                        Console.WriteLine("Product ID: " + id);
                        Console.WriteLine("Item Name: " + prod.Name);
                        Console.WriteLine("Quantity: " + Item.Quantity);
                        Console.WriteLine(" ");
                    }
                    Console.WriteLine("Select an item (by ID)");
                    userInput = Console.ReadLine();
                    List <Inventory> inv = inventorytask.GetInventoryByLocation(Locationid);
                    Console.WriteLine("How much of this item is now in stock?");
                    string newquantity = Console.ReadLine();
                    foreach (Inventory item in inv)
                    {
                        if (item.ProductId == Int32.Parse(userInput))
                        {
                            Inventory updatedinv = inventorytask.GetInventory(item.InventoryId);
                            updatedinv.Quantity = Int32.Parse(newquantity);
                            inventorytask.UpdateInventory(updatedinv);
                            Console.WriteLine("Item has been restocked!");
                        }
                    }



                    break;

                default:
                    //invalid input message;
                    Console.WriteLine("Make a valid selection!");
                    break;
                }
            }while (!userInput.Equals("3"));
        }