コード例 #1
0
        public ActionResult SaveOrder(OrderIndexVM orderIndexVM)
        {
            //saves to the table
            var order = new Order
            {
                CustomerID = orderIndexVM.CustomerID,
                LocationID = orderIndexVM.LocationID,
                Total      = GetTotal(orderIndexVM.DrinkOrders)
            };

            order = _orderBL.AddOrder(order);
            foreach (var item in orderIndexVM.DrinkOrders)
            {
                if (item.Quantity > 0)
                {
                    var drinkOrder = new DrinkOrder
                    {
                        DrinkId  = item.DrinkId,
                        OrderId  = order.OrderID,
                        Quantity = item.Quantity
                    };
                    _orderBL.AddDrinkOrder(drinkOrder);
                }
                var inventory = _inventoryBL.GetInventoryByLocationIDAndDrinkID(order.LocationID, item.DrinkId);
                if (inventory != null)
                {
                    inventory.Quantity -= item.Quantity;
                    _inventoryBL.UpdateInventory(inventory);
                }
            }



            return(RedirectToAction("Index", "Home"));
        }
コード例 #2
0
        public void CreateOrder()
        {
            Console.WriteLine("Enter your Phone Number: ");
            Customer foundCustomer = _customerBL.GetCustomerByName(Console.ReadLine());

            if (foundCustomer == null)
            {
                Console.WriteLine("No customer with that [Phone Number] exists in our Database. Please register to create an order.");
            }
            else
            {
                Console.WriteLine($"{foundCustomer} \n\t");
                Console.WriteLine("Here is a list of our products: ");


                foreach (var item in _productBL.GetProduct())

                {
                    Console.WriteLine(item.ToString());
                }
                double  total;
                Order   newOrder = new Order();
                Product P        = new Product();
                newOrder.Customer     = foundCustomer;
                newOrder.CustomerName = foundCustomer.FirstName + " " + foundCustomer.LastName;
                //Console.WriteLine($"{newOrder.Customer}");
                //Console.WriteLine($"{newOrder.Customer.PhoneNumber}");
                //currentLocation = SearchLocation(Console.ReadLine());
                newOrder.Location = currentLocation;
                Console.WriteLine("Enter the Name of the product you would like to purchase: ");
                Console.WriteLine("[1] Original");
                Console.WriteLine("[2] Barbeque");
                Console.WriteLine("[3] Salt and Vinegar");
                Console.WriteLine("[4] Sour Cream and Onion");
                Product selectProduct = _productBL.GetProductByName(Console.ReadLine());
                newOrder.Product = selectProduct;
                //newOrder.OrderID = int.Parse(Console.ReadLine());
                Console.WriteLine($"You have ordered item #{selectProduct.ProductID}, price {selectProduct.ProductPrice}");
                newOrder.ProdID = selectProduct.ProductID;
                Console.WriteLine("Select the quantity: ");
                newOrder.OrderQuantity = int.Parse(Console.ReadLine());

                total = newOrder.OrderQuantity * (double)selectProduct.ProductPrice;
                newOrder.OrderTotal = total;
                Console.WriteLine($"total: {newOrder.OrderTotal}");

                _orderBL.AddOrder(newOrder);
                Console.WriteLine($"You have Successfully Placed your order! Total: [{newOrder.OrderTotal}]");
            }
        }
コード例 #3
0
        public void PlaceOrder(Location location, decimal total, int drinkID, int drinkQuantityNumber)
        {
            var order = new Dozen2Models.Order
            {
                Customer = Program.currentCustomer,
                Location = location,
                Total    = total,
                DrinkId  = drinkID,
                Quantity = drinkQuantityNumber
            };

            _orderBL.AddOrder(order);
            Console.WriteLine("Your order has been successfully placed!");
        }
コード例 #4
0
        public void CheckoutItems(decimal total, int locId, int custId)
        {
            DateTime now      = DateTime.Now;
            Order    newOrder = new Order();

            newOrder.Total      = total;
            newOrder.Date       = now;
            newOrder.LocationId = locId;
            newOrder.CustomerId = custId;

            _orderBL.AddOrder(newOrder);

            Console.WriteLine($"Purchase complete! \n\t Date: {newOrder.Date} \n\t Total: ${newOrder.Total} \n");
            Log.Information($"New order completed. Details:{newOrder.ToString()}");

            Console.WriteLine($"Thank you for shopping at Jake's Ice Creamery!");
            ExitUI();
        }
コード例 #5
0
        private void PlaceOrders()
        {
            //Customer customer = SearchCustomer();
            Location location = SearchBranch();

            //loction --> inventory --> product (locationId)

            //Todo
            //Display a list of product avaiable products in the selected store
            DisplayProducts(location);

            //ToDo - change date to timestamp instead of input
            DateTime orderDate = _validate.ValidateDate("Enter the order date [yyyy-mm-dd]:");
            //DateTime orderDate = new DateTime();
            Order newOrder     = new Order(orderDate);
            Order createdOrder = _orderBL.AddOrder(customer, location, newOrder);
            Order curOrder     = _orderBL.GetOrder(customer, location, newOrder);

            decimal total = 0;
            string  input;

            total += AddItem(curOrder);
            Console.WriteLine($"Current Total: {total}");
            input = _validate.ValidateValidCommand("More items to add? \n\t[Y] - continue \n\t[N] - proceed order");

            while (input.ToLower() != "n")
            {
                total += AddItem(curOrder);
                Console.WriteLine($"Current Total: {total}");
                input = _validate.ValidateValidCommand("More items to add? \n\t[Y] - continue \n\t[N] - proceed order");
            }

            //To-Do add timestamp to find the order
            _orderBL.UpdateOrderTotal(curOrder, total);
            Console.WriteLine("Order has been placed successfully");
            Console.WriteLine("====================================================");
            Console.WriteLine($"Here is the Order Details for {customer.FullName} \n\tOrderID: {curOrder.Id} Total: ${total} Location: {location.Name}");
            ViewOrderDetails(curOrder);
            Console.WriteLine("====================================================");
        }
コード例 #6
0
 public ActionResult Create(OrderVM model)
 {
     //Debug.WriteLine(_orderBL.GetBread(_orderVM.BreadSelection).Breadtype);
     try
     {
         if (ModelState.IsValid)
         {
             _orderBL.AddOrder(_custBL.GetCustomerById(model.CustomerId), new Orders
             {
                 Id         = model.Id,
                 CustomerId = model.CustomerId,
                 Loaf       = _orderBL.GetBread(model.BreadSelection),
                 BreadCount = model.BreadCount
             }, model.LocationSelection);
             return(RedirectToAction(nameof(Index), new { id = model.CustomerId }));
         }
         return(View(model));
     }
     catch
     {
         Debug.WriteLine("Error");
         return(View(model));
     }
 }
コード例 #7
0
        public void GetStores()
        {
            try
            {
                foreach (var item in _locationBL.GetLocations())
                {
                    Console.WriteLine(item.ToString());
                }
                Console.WriteLine("Enter a Store Code to Shop:");
                int      storeCode        = int.Parse(Console.ReadLine());
                Location selectedLocation = _locationBL.GetSpecificLocation(storeCode);
                if (selectedLocation == null)
                {
                    Console.WriteLine("Error - store code not valid");
                }
                else
                {
                    Console.WriteLine($"{selectedLocation.LocationName} Inventory:");
                    foreach (var item in _itemBL.GetItemsByLocation(storeCode))
                    {
                        Console.WriteLine(item.Product.ToString());
                        Console.WriteLine(item.ToString());
                    }
                    Order          newOrder     = new Order(); //create new order object
                    bool           shop         = true;
                    List <Product> cartProducts = new List <Product>();
                    List <int>     cartQuantity = new List <int>();
                    double         totalCost    = 0.0;
                    do
                    {
                        //Product selectedProduct = null;
                        Console.WriteLine();
                        Console.WriteLine("Select ProductID to add product to your order");
                        Console.WriteLine("Type \'Cancel\' to cancel order or \'Finish\' to complete your order");
                        Console.WriteLine("Selection:");
                        string option = Console.ReadLine();
                        if (option == "Cancel" || option == "cancel")
                        {
                            shop = false;
                        }
                        else if (option == "Finish" || option == "finish")
                        {
                            //Create Order
                            newOrder.Total    = totalCost;
                            newOrder.Location = selectedLocation;
                            bool findCustomer = false;
                            do
                            {
                                Customer orderCust = FindCustomer();
                                if (orderCust == null)
                                {
                                    Console.WriteLine("No matching customer found, try searching again");
                                }
                                else
                                {
                                    newOrder.Customer = orderCust;
                                    findCustomer      = true;
                                }
                            }while(!findCustomer);
                            _orderBL.AddOrder(newOrder);

                            //Add products to ProductOrder
                            int oID = _orderBL.FindOrder(newOrder.Total).OrderID;
                            for (int i = 0; i < cartProducts.Count; i++)
                            {
                                ProductOrder po = new ProductOrder();
                                po.Order    = _orderBL.FindOrder(oID);
                                po.Product  = cartProducts[i];
                                po.Quantity = cartQuantity[i];
                                _productOrderBL.AddProductOrder(po);
                                Console.WriteLine("Order Summary:");
                                Console.WriteLine("--------------");
                                po.ToString();
                                _productBL.ProductsByOrder(po.Order.OrderID);
                            }
                            Console.WriteLine("Order successfully placed!");
                            Log.Information("Order Created");
                            shop = false;
                        }
                        else if (option != "Cancel" && option != "Finish")
                        {
                            foreach (var item in _productBL.GetProducts())
                            {
                                if (int.Parse(option) == item.ProductID)
                                {
                                    cartProducts.Add(item);
                                    Console.WriteLine("Enter quantity:");
                                    int quantity = int.Parse(Console.ReadLine());
                                    cartQuantity.Add(quantity);
                                    totalCost = (totalCost) + (item.Price * quantity);
                                }
                            }
                        }
                    }while (shop);
                }
            }
            catch
            {
                Console.WriteLine("Something went wrong...canceling order");
            }
        }
コード例 #8
0
        public void GetStores()
        {
            foreach (var element in _locationBL.GetLocations())
            {
                Console.WriteLine(element.ToString());
            }
            Console.WriteLine("Enter a Store Code: ");
            int      storeCode         = int.Parse(Console.ReadLine());
            Location specifiedLocation = _locationBL.GetSpecifiedLocation(storeCode);

            if (specifiedLocation == null)
            {
                Console.WriteLine("Invalid code.");
            }
            else
            {
                Console.WriteLine($"{specifiedLocation.LocationName} Inventory: ");
                foreach (Drink element in _drinkBL.GetDrinksByLocation(storeCode))
                {
                    Console.WriteLine(element.DrinkName.ToString());
                    //not sure if this will work ^^^^^
                }

                Order        newOrder       = new Order();
                bool         shop           = true;
                List <Drink> drinkCart      = new List <Drink>();
                List <int>   quantityInCart = new List <int>();
                decimal      total          = 0.0m;
                do
                {
                    Console.WriteLine("Select Drink to add to your order");
                    Console.WriteLine("Type 'Submit' when you're finished.");
                    Console.WriteLine("If you wish to cancel, type 'Cancel'");
                    Console.WriteLine("Selection: ");

                    string selection = Console.ReadLine();

                    if (selection == "cancel" || selection == "Cancel")
                    {
                        shop = false;
                    }
                    else if (selection == "submit" || selection == "Submit")
                    {
                        newOrder.Total    = total;
                        newOrder.Location = specifiedLocation;
                        Customer customerOrder = FindCustomer();

                        if (customerOrder == null)
                        {
                            Console.WriteLine("cannot find customer");
                        }
                        else
                        {
                            newOrder.Customer = customerOrder;
                        }

                        _orderBL.AddOrder(newOrder);
                    }
                }while (shop);
            }
        }
コード例 #9
0
 public async Task <bool> AddOrder(long UserId)
 {
     return(await orderBL.AddOrder(UserId));
 }
コード例 #10
0
        public void PlaceOrder()
        {
            Console.Clear();
            AsciiHeader.AsciiHead();
            Customer customer = new Customer();

            customerSearch.Start(customer);



            //we have the customer
            //we need the location next
            Boolean  stay     = true;
            Location location = new Location();

            while (stay)
            {
                Console.Clear();
                AsciiHeader.AsciiHead();
                Console.WriteLine("Please select customer store location");
                Console.WriteLine("[0] Tampa");
                Console.WriteLine("[1] Orlando");
                string userInput = Console.ReadLine();
                switch (userInput)
                {
                case "0":
                    location = _locationBL.GetSpecifiedLocation(20000);
                    stay     = false;
                    break;

                case "1":
                    location = _locationBL.GetSpecifiedLocation(20001);
                    stay     = false;
                    break;

                default:
                    Console.WriteLine("Not a valid menu option!");
                    break;
                }
                //Console.WriteLine(location);
            }
            Cart cart = new Cart();

            //Console.WriteLine(customer);
            //now, with both a customer and location, we can create a cart OR call a cart
            //if the customer's cart already exists, it will use that cart
            try
            {
                cart = _cartBL.FindCart(customer.CustomerID);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Something went wrong");
            }


            //before we start assigning products to carts, we need to know our inventory ID list to pass into the product search
            List <Inventory> inventories         = _inventoryBL.GetInventory();
            List <Inventory> specificInventories = new List <Inventory>();

            foreach (Inventory i in inventories)
            {
                if (i.InventoryLocation == location.LocationID)
                {
                    specificInventories.Add(i);
                }
            }

            //THIS is where we would want to call our product search menu
            // we want to basically run this, then on complete, create a new cartproduct object
            // we can check against inventory amount here!!!
            try
            {
                productSearch.Start(location, cart.CartID, inventories);
            }
            catch (System.ArgumentOutOfRangeException ex)
            {
                Log.Error(ex, "Someone tried to order a product that didn't exist");
                Console.WriteLine("Sorry, the requested product does not exist at your location.\nPlease try again.");
                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                productSearch.Start(location, cart.CartID, inventories);
            }



            List <CartProducts> cartProducts = _cartProductsBL.FindCartProducts(cart.CartID);

            decimal costTotal = 0;

            LineSeparator line = new LineSeparator();

            Console.WriteLine("Please confirm your order for processing:");
            Console.WriteLine("Products Ordered:");
            foreach (CartProducts x in cartProducts)
            {
                Product currentProduct = _productBL.GetProductByID(x.ProductID);

                decimal currentProductCost = currentProduct.ProductPrice.Value * x.ProductCount.Value;
                costTotal = costTotal + currentProductCost;
                line.LineSeparate();
                Console.WriteLine($"| Product Name: {currentProduct.ProductName} | Product Quantity: {x.ProductCount} | Individual Product Cost: {currentProductCost}");
                line.LineSeparate();
            }
            line.LineSeparate();
            Console.WriteLine($"| Total Cost: {costTotal}");


            Console.WriteLine("Is this order accurate?");
            Console.WriteLine("[0] Yes");
            Console.WriteLine("[1] No");
            string confirmationInput;

            confirmationInput = Console.ReadLine();
            bool stayConfirm  = true;
            bool processOrder = true;

            while (stayConfirm)
            {
                switch (confirmationInput)
                {
                case "0":
                    Console.WriteLine("Fantastic! Please press enter to begin order processing.");
                    Console.ReadLine();
                    processOrder = true;
                    stayConfirm  = false;
                    break;

                case "1":
                    Console.WriteLine("Okay, please update your order as necessary and return to this confirmation page.");
                    Console.WriteLine("Please press enter.");
                    Console.ReadLine();

                    processOrder = false;
                    stayConfirm  = false;
                    break;

                default:
                    Console.WriteLine("Not a valid menu option!");
                    break;
                }
            }

            if (processOrder == true)
            {
                //time to process the order
                Order finalizedOrder = new Order();

                finalizedOrder.CartID     = cart.CartID;
                finalizedOrder.Customer   = customer;
                finalizedOrder.CustomerID = customer.CustomerID;
                finalizedOrder.LocationID = location.LocationID;
                finalizedOrder.OrderDate  = DateTime.Now;



                _orderBL.AddOrder(finalizedOrder);

                //we will need to retrieve the order that was just added for it's ID!
                //this will let us process what items were included in the order
                Order orderForItemsProcessing = _orderBL.GetSpecifiedOrder(finalizedOrder.OrderDate);
                //create a new order item list
                List <OrderItem> orderItems = new List <OrderItem>();

                //add each new orderItem to our database
                foreach (CartProducts p in cartProducts)
                {
                    OrderItem orderProcessing = new OrderItem
                    {
                        OrderItemsQuantity = p.ProductCount,
                        OrderID            = orderForItemsProcessing.OrderID,
                        productID          = p.ProductID,
                    };

                    _orderItemsBL.AddOrderItem(orderProcessing);
                }
                //flush the cart once the order is complete.
                foreach (CartProducts cartprod in cartProducts)
                {
                    _cartProductsBL.RemoveCartProducts(cartprod);
                }

                Log.Information("Order placed successfully");
                Console.WriteLine("Order placed successfully!");
                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                Console.Clear();
            }


            //we now have EVERYTHING ready (I think)



            //List<OrderItem> orderItemsToConfirm = _orderItemsBL.GetOrderItems(orderForItemsProcessing.OrderID);


            //now that we have a cart, we need to find products
            //then add them to a new cartproducts table so the cart
            //can reference them
            //we will call cartproduct BL to create a new cartproduct
            //every time something is added to the inventory.
            //then, we can return a list of cartproducts after?



            //then create an order when products/total are ready!
        }
コード例 #11
0
        public void Start()
        {
            int    GetCustomerId = AddCustomer();
            Random nums          = new Random();
            int    ID            = nums.Next(1111, 9999);

            string FoundLocation = LocationFind();



            Orders newOrder     = new Orders(ID, 0, GetCustomerId, 0, FoundLocation);
            Orders createdOrder = _orderBL.AddOrder(newOrder);

            // int ProductQuantity = DeleteProduct();
            // Product orderProduct = new Product(ProductQuantity);
            // Product orderedProduct = _productBL.DeleteProduct(orderProduct);

            // async Task Invoke(HttpContext ctx, IDataService svc2)
            // {
            //     ILogger<EventSourceLoggerProvider> loggerEvent =
            //     ctx.RequestServices.GetService<ILogger<EventSourceLoggerProvider>>();
            // }

            // DateTime localDate = DateTime.Now();



            bool repeat = true;

            do
            {
                Console.WriteLine("Which product do you wish to purchase? (Mango Twango = 0, Hickory Dickory = 1, Hollapeno = 2, Heat Wave = 3, Scorpion Sting = 4, Pepper Plague = 5) Press 6 to Exit.");
                List <Products> products = _productBL.GetAllProducts();
                foreach (Products product in products)
                {
                    Console.WriteLine(product.ToString());
                }
                ;

                string input = Console.ReadLine();

                switch (input)
                {
                case "0":
                    int Quant = 1;
                    newOrder.OrderQuantity = newOrder.OrderQuantity + Quant;
                    double Price = 9.00;
                    newOrder.OrderTotal = newOrder.OrderTotal + Price;
                    _orderBL.UpdateOrder(newOrder);
                    DecrementInventory(1, FoundLocation);
                    // orderProduct.OrderQuantity = orderedProduct.OrderQuantity - 1;
                    Console.WriteLine("Purchased!");
                    // logger.LogInformation("Purchase Log");
                    break;

                case "1":
                    int Quant1 = 1;
                    newOrder.OrderQuantity = newOrder.OrderQuantity + Quant1;
                    double Price1 = 9.00;
                    newOrder.OrderTotal = newOrder.OrderTotal + Price1;
                    _orderBL.UpdateOrder(newOrder);
                    DecrementInventory(2, FoundLocation);
                    Console.WriteLine("Purchased!");
                    break;

                case "2":
                    int Quant2 = 1;
                    newOrder.OrderQuantity = newOrder.OrderQuantity + Quant2;
                    double Price2 = 10.00;
                    newOrder.OrderTotal = newOrder.OrderTotal + Price2;
                    _orderBL.UpdateOrder(newOrder);
                    DecrementInventory(3, FoundLocation);
                    Console.WriteLine("Purchased!");
                    break;

                case "3":
                    int Quant3 = 1;
                    newOrder.OrderQuantity = newOrder.OrderQuantity + Quant3;
                    double Price3 = 10.00;
                    newOrder.OrderTotal = newOrder.OrderTotal + Price3;
                    _orderBL.UpdateOrder(newOrder);
                    DecrementInventory(4, FoundLocation);
                    Console.WriteLine("Purchased!");
                    break;

                case "4":
                    int Quant4 = 1;
                    newOrder.OrderQuantity = newOrder.OrderQuantity + Quant4;
                    double Price4 = 12.00;
                    newOrder.OrderTotal = newOrder.OrderTotal + Price4;
                    _orderBL.UpdateOrder(newOrder);
                    DecrementInventory(5, FoundLocation);
                    Console.WriteLine("Purchased!");
                    break;

                case "5":
                    int Quant5 = 1;
                    newOrder.OrderQuantity = newOrder.OrderQuantity + Quant5;
                    double Price5 = 12.00;
                    newOrder.OrderTotal = newOrder.OrderTotal + Price5;
                    _orderBL.UpdateOrder(newOrder);
                    DecrementInventory(6, FoundLocation);
                    Console.WriteLine("Purchased!");
                    break;

                case "6":
                    Console.WriteLine("Have a nice day!");
                    repeat = false;
                    break;

                default:
                    Console.WriteLine("Please enter a valid option");
                    submenu.Start();
                    break;
                }
            } while (repeat);
        }
コード例 #12
0
        /// <summary>
        /// Over-arching order method that gives customer the tools to perform an order
        /// </summary>
        private void OrderDog()
        {
            string input;
            bool   repeat = true;

            do
            {
                Console.WriteLine("What store would you like to buy from?");
                Console.WriteLine("[0] View list of stores");
                Console.WriteLine("[1] I know what store I want to order from");
                input = Console.ReadLine();
                switch (input)
                {
                case "0":
                    foreach (StoreLocation s in ViewStoreList())
                    {
                        Console.WriteLine(s.ToString());
                    }
                    repeat = false;
                    break;

                case "1":
                    repeat = false;
                    break;

                default:
                    Console.WriteLine("Invalid input");
                    break;
                }
            }while(repeat);
            repeat = true;
            do
            {
                Console.WriteLine("Enter the store you'd like to buy from");
                Console.WriteLine("[0] View list of stores");
                Console.WriteLine("[1] I know what store I want to order from");
                input = Console.ReadLine();
                switch (input)
                {
                case "0":
                    foreach (StoreLocation s in ViewStoreList())
                    {
                        Console.WriteLine(s.ToString());
                    }
                    repeat = false;
                    break;

                case "1":
                    repeat = false;
                    break;

                default:
                    Console.WriteLine("Invalid input");
                    break;
                }
            }while(repeat);

            ViewStoreInv();
            repeat        = true;
            _runningCount = 0;
            //string storeLocation = validation.ValidateString("Enter the store's name:");
            //string storeAddress = validation.ValidateAddress("Enter the store's address in format CityName, ST");
            _dogOrder = new DogOrder(_dogBuyer, 0, _storeLoBL.GetStore(_address, _location));
            do
            {
                char   gender   = validation.ValidateGender("Enter the gender of dog you'd like to purchase");
                string breed    = validation.ValidateString("Enter the breed of the Dog you'd like to purchase");
                int    quant    = validation.ValidateInt("Enter how many you would like to purchase");
                Item   lineItem = _storeLoBL.FindItem(new StoreLocation(_address, _location), new Dog(breed, gender, 1000.0), quant);
                if (lineItem != null)
                {
                    _dogOrder.AddItemToOrder(lineItem);
                    _dogOrder.Total += ((double)quant * lineItem.Dog.Price);
                }
                else
                {
                    Console.WriteLine("Not a valid item");
                }
                Console.WriteLine("Enter c to complete order or any other character to continue");
                if (Console.ReadLine().Equals("c"))
                {
                    repeat = false;
                }
                //get all the items you want to order
            }while(repeat);
            if (_orBL.AddOrder(_dogOrder) == null)
            {
                Console.WriteLine("If you're seeing this, something went terribly wrong");
            }
            //send the list of items to the database and remove them from the store's inventory
        }