Пример #1
0
        public void ChooseLocation(int custId)
        {
            bool stayChooseLocation = true;

            Console.WriteLine("\nChoose a location.");
            do
            {
                //display locations
                int i = 1;
                foreach (var item in _locationBL.GetLocations())
                {
                    Console.WriteLine($"[{item.Id}] {item.Address} {item.City}, {item.State} ({item.Zipcode})");
                    i++;
                }
                Console.WriteLine($"[{i}] Exit");
                Console.WriteLine("Enter a number: ");

                //get user input
                int userInput = int.Parse(Console.ReadLine());

                if (_locationBL.GetLocationById(userInput) != null)
                {
                    ShopInventory(userInput, custId);
                }
                else if (userInput == i)
                {
                    ExitUI();
                }
                else
                {
                    Console.WriteLine("Not part of menu! Please try again.");
                    continue;
                }
            } while (stayChooseLocation);
        }
Пример #2
0
        public IActionResult LocationOrders(int?LocationID = null, int?SortBy = null)
        {
            ViewBag.SortOptions = GetSortOptions();
            var locations = _locationBL.GetLocations();

            ViewBag.Locations = locations
                                .Select(i => new SelectListItem
            {
                Value = i.LocationID.ToString(),
                Text  = $"{i.LocationName}, {i.State}"
            }).ToList();


            var locationOrdersVM = _orderBL.GetLocationOrdersVM(LocationID, SortBy);

            return(View(locationOrdersVM));
        }
Пример #3
0
 public void GetLocations()
 {
     Console.Clear();
     foreach (var item in _locationBL.GetLocations())
     {
         Console.WriteLine(item.ToString());
     }
 }
Пример #4
0
 public void ViewLocations()
 {
     foreach (var item in _locationBL.GetLocations())
     {
         Console.WriteLine(item.ToString());
     }
     Console.WriteLine("Press any key to continue");
     Console.ReadLine();
 }
Пример #5
0
        public ActionResult Create(CustomerCRVM newCustomer)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _customerBL.AddCustomer(_mapper.cast2Customer(newCustomer));
                    Log.Information($"Customer created-- Email: {newCustomer.CustomerEmail}");

                    //move this loop to BL
                    foreach (var loc in _locationBL.GetLocations())
                    {
                        CustomerCart cart = new CustomerCart();
                        cart.CustId         = _customerBL.GetCustomerByEmail(newCustomer.CustomerEmail).Id;
                        cart.LocId          = loc.Id;
                        cart.CurrentItemsId = _orderLineItemBL.Ident_Curr() + 1;
                        _cartBL.AddCustomerCart(cart);
                        CustomerOrderLineItem orderLineItem = new CustomerOrderLineItem();
                        orderLineItem.OrderId   = cart.CurrentItemsId;
                        orderLineItem.ProdId    = null;
                        orderLineItem.Quantity  = 0;
                        orderLineItem.ProdPrice = 0;
                        _orderLineItemBL.AddCustomerOrderLineItem(orderLineItem);
                    }
                    //Helper.WriteInformation($"Customer created-- Email: {newCustomer.CustomerEmail}");

                    return(Redirect("/Customer/Login"));
                }
                catch (Exception e)
                {
                    Helper.WriteError(e, "Error");
                    Helper.WriteFatal(e, "Fatal");
                    Helper.WriteVerbose(e, "Verbose");
                    return(View());
                }
                finally
                {
                }
            }
            return(View());
        }
Пример #6
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");
            }
        }
        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);
            }
        }
Пример #8
0
        public void LocationHistory()
        {
            foreach (var item in _locationBL.GetLocations())
            {
                Console.WriteLine(item.ToString());
            }
            Location loc      = null;
            bool     foundLoc = false;
            int      option;

            do
            {
                Console.WriteLine("Enter store code to view inventory history:");
                option = int.Parse(Console.ReadLine());
                loc    = _locationBL.GetSpecificLocation(option);
                if (loc == null)
                {
                    Console.WriteLine("Invalid location id, please search again");
                }
                else
                {
                    foundLoc = true;
                }
            }while(!foundLoc);
            Console.WriteLine("Select order history format:");
            Console.WriteLine("\t[1] - Date(Ascending)\n\t[2] - Date(Descending)\n\t[3] - Total(Highest)\n\t[4] - Total(Lowest)");
            option = int.Parse(Console.ReadLine());
            switch (option)
            {
            case 1:
                foreach (var item in _orderBL.GetLocationOrderASC(loc.LocationID))
                {
                    Console.WriteLine(item.ToString());
                    _productBL.ProductsByOrder(item.OrderID);
                }
                break;

            case 2:
                foreach (var item in _orderBL.GetLocationOrderDESC(loc.LocationID))
                {
                    Console.WriteLine(item.ToString());
                    _productBL.ProductsByOrder(item.OrderID);
                }
                break;

            case 3:
                foreach (var item in _orderBL.GetLocationOrderASCTotal(loc.LocationID))
                {
                    Console.WriteLine(item.ToString());
                    _productBL.ProductsByOrder(item.OrderID);
                }
                break;

            case 4:
                foreach (var item in _orderBL.GetLocationOrderDESCTotal(loc.LocationID))
                {
                    Console.WriteLine(item.ToString());
                    _productBL.ProductsByOrder(item.OrderID);
                }
                break;

            default:
                Console.WriteLine("Incorrect option, please try again");
                break;
            }
        }
Пример #9
0
 // GET: LocationController
 public ActionResult Index()
 {
     HttpContext.Session.Remove("LocId");
     return(View(_locationBL.GetLocations().Select(x => _mapper.cast2LocationIndexVM(x)).ToList()));
 }