コード例 #1
0
        /// <summary>
        /// Lets you update Customer's details if you have necessary authorization.
        /// </summary>
        /// <returns></returns>
        public async Task UpdateTheCustomerAsync()
        {
            // Customer updatedCustomer, string updatedFirstName, string updatedLastName

            Console.WriteLine("\n************************* Welcome to the  Customer Update menu ******************************\n");

            // Check if the current user is admin or not
            if (!await IdendityValidator.IsAdmin())
            {
                string text = "\nUsername and or password failed...\nPlease enter your username and password carefully next time.\nExiting to main menu now....\nAny unauthorized attempts to subvert the system will be logged and reported to the relevant authority.\n";
                foreach (char c in text)
                {
                    Console.Write(c);
                    Thread.Sleep(40);
                }
                return;
            }

            Console.Write("\nEnter Id of the Customer you want update: ");
            var     customerId = Console.ReadLine();
            Program p          = new Program();

            var customerToUpdate = await GetCustomerByIdAsync(customerId);

            if (customerToUpdate != null)
            {
                Console.WriteLine($"You sure want to Update {customerToUpdate.FirstName} {customerToUpdate.LastName} 's details from db? ");
                Console.Write("Write yes and press enter to continue: ");
                var result = Console.ReadLine();
                if (result.ToLower().Trim() != "yes")
                {
                    return;
                }
                else
                {
                    Console.Write("Write the updated first name: ");
                    var updatedFirstName = Console.ReadLine();
                    Console.Write("Write the updated last name: ");
                    var updatedLastName = Console.ReadLine();

                    customerToUpdate.FirstName = updatedFirstName;
                    customerToUpdate.LastName  = updatedLastName;
                    var customerService = Container.GetService <ICustomerRepository>();
                    await customerService.UpdateCustomerAsync(customerToUpdate);

                    Console.Write("Record Succesfully Updated");
                    Console.Write("\nReturning to the main menu...");
                    Thread.Sleep(3000);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Deletes Customer form the database if the user has authorization.
        /// </summary>
        /// <returns></returns>
        public async Task DeleteCustomerAsync()
        {
            Console.WriteLine("\n************************* Welcome to the Customer delete menu ******************************\n");

            // Check if the current user is admin or not
            if (!await IdendityValidator.IsAdmin())
            {
                string text = "\nUsername and or password failed...\nPlease enter your username and password carefully next time.\nExiting to main menu now....\nAny unauthorized attempts to subvert the system will be logged and reported to the relevant authority.\n";
                foreach (char c in text)
                {
                    Console.Write(c);
                    Thread.Sleep(40);
                }
                return;
            }

            // Asks for the Customer's Id whom should be deleted.
            Console.Write("Enter Id of the Customer you want delete: ");

            var customerId = Console.ReadLine();

            // flag to disallow GetCustomerByIdAsync method to display message.
            flag = false;
            // Note : customerId of type string gets converted to int inside GetCustomerByIdAsync method
            var customerToDelete = await GetCustomerByIdAsync(customerId);

            var result1         = customerToDelete;
            var customerService = Container.GetService <ICustomerRepository>();

            if (customerToDelete != null)
            {
                Console.WriteLine($"You sure want to delete {customerToDelete.FirstName} {customerToDelete.LastName} with Id {customerToDelete.Id} from db? ");
                var result = Console.ReadLine();
                if (result.ToLower() == "yes")
                {
                    await customerService.DeleteCustomerAsync(customerToDelete.Id);

                    Console.WriteLine($"{customerToDelete.FirstName} {customerToDelete.LastName} deleted.");
                }
            }
            else
            {
                Console.WriteLine("Customer not found");
            }
        }
コード例 #3
0
        /// <summary>
        /// Lets user to create a account, if user has further authorization, user can create an account of admin type.
        /// </summary>
        /// <returns>void</returns>
        public async Task CreateACustomerAsync()
        {
            Console.WriteLine("************************* Welcome to the Customer Creation menu ******************************\n");

            Console.WriteLine("Your email address will be used as the username.");
            // initalizes the variable for holding user inputs.
            var firstName = "";
            var lastName  = "";
            var street    = "";
            var city      = "";
            var state     = "";
            var zip       = "";

            // Check for empty inputs and prompts user again to correct if invalid of empty entries attempted.
            while (true)
            {
                Console.Write("\nEnter your first name: ");
                firstName = Console.ReadLine();
                Console.Write("Enter your last name: ");
                lastName = Console.ReadLine();
                Console.Write("Enter your Street Address: ");
                street = Console.ReadLine();
                Console.Write("Enter your City: ");
                city = Console.ReadLine();
                Console.Write("Enter your State: ");
                state = Console.ReadLine();
                Console.Write("Enter your Zip: ");
                zip = Console.ReadLine();

                // Sanitize the inputs
                if (firstName.Sanitize() == "empty" || lastName.Sanitize() == "empty" || street.Sanitize() == "empty" ||
                    city.Sanitize() == "empty" || state.Sanitize() == "empty" || zip.Sanitize() == "empty")
                {
                    Console.WriteLine("System doesn't accept empty entries \nPlease enter again, or press Q to return to the main menu ");
                    var keyinfo = Console.ReadKey();

                    if (keyinfo.Key == ConsoleKey.Q)
                    {
                        Console.Clear(); return;
                    }
                    continue;
                }
                firstName.Sanitize();
                lastName = lastName.Sanitize();
                street   = street.Sanitize();
                city     = city.Sanitize();
                state    = state.Sanitize();
                zip      = zip.Sanitize();
                break;
            }


            var email       = "";
            var phoneNumber = "";
            // password must atleast contain one digit, one upper case and one lower case with no whitespace
            var  password        = "";
            bool fromPhoneNumber = false;
            bool fromPassword    = false;

            while (true)
            {
                if (fromPhoneNumber == false || fromPassword == false)
                {
                    Console.Write("Enter your email: ");
                    email = Console.ReadLine();
                    // Sanitize email
                    email = email.Sanitize();
                    if (!email.IsValidEmail())
                    {
                        Console.WriteLine("Invalid Email format");
                        continue;
                    }
                }

                if (fromPassword == false)
                {
                    Console.Write("Enter your phone no: ");
                    phoneNumber = Console.ReadLine();
                    // Sanitize phone number
                    phoneNumber = phoneNumber.Sanitize();
                    if (!phoneNumber.IsValidPhoneNumber())
                    {
                        Console.WriteLine("Invalid Phone number format");
                        Console.Write($"\t123-456-7890\n\t(123) 456-7890\n\t123 456 7890\n\t123.456.7890\n\t+91 (123) 456-7890\t");
                        fromPhoneNumber = true;
                        continue;
                    }
                }

                Console.Write("Password must contain atleast contain one digit, one upper case and one lower case and no whitespace\n");
                Console.Write("Enter your preferred password: "******"Enter your password again for confirmation: ");
                var password2 = Orb.App.Console.ReadPassword();

                if (password.IsValidPassword())
                {
                    Console.Clear();
                    var origRow = Console.CursorTop;
                    var origCol = Console.CursorLeft;
                    Console.Clear();
                    if (password != password2)
                    {
                        Console.WriteLine("Sorry your password didn't match");

                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Enter valid password...");
                    continue;
                }
            }

            // Check if user has Admin privilege
            Console.Write("Are you one of our staff members? \nType yes and press enter if you are, otherwise press any other key to continue : ");
            string staffCheck = "";

            staffCheck = Console.ReadLine();
            if (staffCheck.Trim().ToLower() == "yes")
            {
                if (!await IdendityValidator.IsAdmin())
                {
                    // loops through the character of string on by one and display it in the console.
                    // link : https://stackoverflow.com/questions/27718901/writing-one-character-at-a-time-in-a-c-sharp-console-application
                    // author : https://stackoverflow.com/users/22656/jon-skeet
                    string text = "\nUsername and or password failed...\nPlease enter your username and password carefully next time.\nExiting to main menu now....\nAny unauthorized attempts to subvert the system will be logged and reported to the relevant authority.\n";
                    foreach (char c in text)
                    {
                        Console.Write(c);
                        Thread.Sleep(40);
                    }
                    return;
                }
                else
                {
                    isAdmin = true;
                }
            }

            if (!string.IsNullOrEmpty(firstName) &&
                !string.IsNullOrEmpty(lastName) && !string.IsNullOrEmpty(password))
            {
                // Create a customer from user inserted strings

                var customerAddress = new CustomerAddress {
                    Street = street, City = city, State = state, Zip = zip
                };
                var customer = new Customer {
                    FirstName = firstName, LastName = lastName, Password = password, Email = email, PhoneNo = phoneNumber, UserTypeId = isAdmin ? 1 : 2, CustomerAddress = customerAddress
                };


                // conjure up an interface to service layer
                var insertCustomer = Container.GetService <ICustomerRepository>();

                // pass the customer up the chain through DI injected dbcontext to the service layer
                await insertCustomer.InsertCustomerAsync(customer);

                Console.WriteLine("Customer Creation successful");
                Console.WriteLine($"Welcome to the Console Shopper family {firstName} {lastName}");
                if (isAdmin)
                {
                    isAdmin = false;
                }
            }
            else
            {
                return;
            }
        }
コード例 #4
0
        /// <summary>
        /// Adds Product Inventory to Store (increases quantity).
        /// </summary>
        /// <returns></returns>
        public async Task AddProductInventoryToStoreAsync()
        {
            // Customer updatedCustomer, string updatedFirstName, string updatedLastName

            Console.WriteLine("************************* Welcome to the  Product Inventory Update menu ******************************\n");

            //Check if the current user is admin or not
            if (!await IdendityValidator.IsAdmin())
            {
                string text = "\nUsername and or password failed...\nPlease enter your username and password carefully next time.\nExiting to main menu now....\nAny unauthorized attempts to subvert the system will be logged and reported to the relevant authority.\n";
                foreach (char c in text)
                {
                    Console.Write(c);
                    Thread.Sleep(40);
                }
                return;
            }
            Console.WriteLine("*****************Product Inventory Item********************\n");
            Dictionary <string, string> instruments = new Dictionary <string, string>()
            {
                { "P00001", "Piano" },
                { "P00002", "Flute" },
                { "P00003", "Accordion" },
                { "P00004", "Piccolo" },
                { "P00005", "Trombone" },
                { "P00006", "Violin" },
                { "P00007", "Guitar" },
                { "P00008", "Bagpipes" },
                { "P00009", "Ukulele" },
                { "P00010", "Saxophone" }
            };

            Console.Write("*****Product Code************ Item *******\n");
            foreach (KeyValuePair <string, string> entry in instruments)
            {
                Console.WriteLine($"{entry.Key.PadLeft(15)} \t{entry.Value.PadLeft(10)}");
            }

            // Validation for product code.
            var productCode = "";

            while (true)
            {
                Console.Write("\nEnter Product code of product to update: ");
                productCode = Console.ReadLine();

                Regex regex = new Regex(@"^[P][0]{4}[1-9]|10$");
                Match match = regex.Match(productCode);
                if (!match.Success)
                {
                    Console.WriteLine("Product code did not match: ");
                    continue;
                }
                else
                {
                    break;
                }
            }

            var productToUpdate = await GetProductByCodeAsync(productCode);

            if (productToUpdate != null)
            {
                Console.WriteLine($"You sure you want to add  {productToUpdate.Product.Name} with ,code {productToUpdate.Product.ProductCode} into the inventory? ");
                Console.Write("Write yes and press enter to continue: ");
                var result = Console.ReadLine();
                if (result.ToLower().Trim() != "yes")
                {
                    return;
                }
                else
                {
                    // Choose store location

                    /*
                     *      Florida
                     *      New York
                     *      Texas
                     *      Washington
                     *      California
                     *
                     */

                    string[] locations = { "Florida", "New York", "Texas", "Washington", "California" };

                    var storeLocation = "";
                    int storeId       = 0;
                    while (true)
                    {
                        Console.WriteLine("\nPress 1 for Florida\nPress 2 for New York\nPress 3 for Texas\nPress 4 for Washington\nPress 5 for California\n");
                        storeLocation = Console.ReadLine();
                        if (storeLocation == "1" || storeLocation == "2" || storeLocation == "3" || storeLocation == "4" || storeLocation == "5")
                        {
                            storeId = ParseString.ToInt(storeLocation);
                            if (storeId == 0)
                            {
                                Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid input"); continue;
                            }
                            break;
                        }
                        continue;
                    }
                    var quantity       = "";
                    var parsedQuantity = 0;
                    productToUpdate.StoreId = storeId;
                    while (true)
                    {
                        // Checks if StoreId 0 which means input provided was not valid one.
                        Console.Write($"How many {productToUpdate.Product.Name} do you want to add?: ");
                        quantity       = Console.ReadLine();
                        parsedQuantity = ParseString.ToInt(quantity);
                        if (parsedQuantity != 0)
                        {
                            productToUpdate.LoggedUserId = SessionHolder.UserId;
                            productToUpdate.ChangedDate  = DateTimeOffset.Now.LocalDateTime;
                            productToUpdate.Quantity    += parsedQuantity;
                            break;
                        }
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Invalid input");
                        continue;
                    }


                    var productService = Container.GetService <IProductRepository>();
                    await productService.UpdateProductAsync(productToUpdate);

                    // Empty the session userId
                    SessionHolder.UserId = 0;
                    Console.WriteLine("Product Inventory Updated Successfully");
                    return;
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Lets you update product's price if you have necessary authorization.
        /// </summary>
        /// <returns></returns>
        public async Task UpdateProductPriceAsync()
        {
            // Customer updatedCustomer, string updatedFirstName, string updatedLastName

            Console.WriteLine("************************* Welcome to the  Product Inventory Update menu ******************************\n");

            //Check if the current user is admin or not
            if (!await IdendityValidator.IsAdmin())
            {
                string text = "\nUsername and or password failed...\nPlease enter your username and password carefully next time.\nExiting to main menu now....\nAny unauthorized attempts to subvert the system will be logged and reported to the relevant authority.\n";
                foreach (char c in text)
                {
                    Console.Write(c);
                    Thread.Sleep(40);
                }
                return;
            }
            Console.WriteLine("*****************Product Inventory Item********************\n");
            Dictionary <string, string> instruments = new Dictionary <string, string>()
            {
                { "P00001", "Piano" },
                { "P00002", "Flute" },
                { "P00003", "Accordion" },
                { "P00004", "Piccolo" },
                { "P00005", "Trombone" },
                { "P00006", "Violin" },
                { "P00007", "Guitar" },
                { "P00008", "Bagpipes" },
                { "P00009", "Ukulele" },
                { "P00010", "Saxophone" }
            };

            Console.Write("*****Product Code************ Item *******\n");
            foreach (KeyValuePair <string, string> entry in instruments)
            {
                Console.WriteLine($"{entry.Key.PadLeft(15)} \t{entry.Value.PadLeft(10)}");
            }

            // Validation for product code.
            var productCode = "";

            while (true)
            {
                Console.Write("\nEnter Product code of product to update: ");
                productCode = Console.ReadLine();

                Regex regex = new Regex(@"^[P][0]{4}[1-9]|10$");
                Match match = regex.Match(productCode);
                if (!match.Success)
                {
                    Console.WriteLine("Product code did not match: ");
                    continue;
                }
                else
                {
                    break;
                }
            }



            var productToUpdate = await GetProductByCodeAsync(productCode);

            if (productToUpdate != null)
            {
                Console.WriteLine($"Want to change product with Name : {productToUpdate.Product.Name}, Code : {productToUpdate.Product.ProductCode}, Price : {productToUpdate.Product.Price} 's details from db? ");
                Console.Write("Write yes and press enter to continue:");
                var result = Console.ReadLine();
                if (result.ToLower().Trim() != "yes")
                {
                    return;
                }
                else
                {
                    Console.WriteLine("Enter the updated price: ");
                    var price          = Console.ReadLine();
                    var convertedPrice = 0.0M;
                    if (decimal.TryParse(price, out convertedPrice))
                    {
                        productToUpdate.ChangedDate   = DateTimeOffset.Now.LocalDateTime;
                        productToUpdate.LoggedUserId  = SessionHolder.UserId;
                        productToUpdate.Product.Price = convertedPrice;
                    }
                    var productService = Container.GetService <IProductRepository>();
                    await productService.UpdateProductAsync(productToUpdate);

                    SessionHolder.UserId = 0;
                    Console.WriteLine("Product Price Updated Successfully");
                    return;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Adds order from the customer to the database.
        /// </summary>
        /// <returns></returns>
        public async Task AddOrderToStoreAsync()
        {
            #region List of things done in this method.

            /*
             *   * 1. Check for users Cusomer's Credentials.
             * Create order and orderline objects.
             *
             *  2. Ask Customer to choose the Store location.
             *      => take Store location from here and put it in order object.
             *  3. Ask Customer about which product/products and what quantites they want to order.
             *      => Show the list of products, aviliable quantites and their respective prices to the user.
             *  4. Allow customers to choose multiple products with multiple quantities.
             *      => hold the product code + quantity in a dictionary.
             *  5. Ask user to confirm the purchase.
             *  6. Insert into order the
             *      => the userId
             *      => the storeLocation
             *      => and time of purchase.
             *  7. Take out productCode and quantity one by one
             *      => Insert into the orderline object
             *          => InventoryItemId(i.e: product Id)
             *          => Quantity
             *          => Price
             *          => OrderId
             *      => Decrease the Quantity in InventoryItem after purchase.
             *
             */
            #endregion

            Console.WriteLine("************************* Welcome to the  Order menu ******************************\n");

            #region 1. Customer check (Username Susy: Password: password)
            //Check if the current user is admin or not
            if (!await IdendityValidator.IsCustomer())
            {
                string text = "\nYou will need to login from your Customer account to place an order....\nExiting to main menu now....\nAny unauthorized attempts to subvert the system will be logged and reported to the relevant authority.\n";
                foreach (char c in text)
                {
                    Console.Write(c);
                    Thread.Sleep(40);
                }
                return;
            }
            #endregion

            #region 2. StordId Setter
            // Ask user to choose the store location.
            string[] locations = { "Florida", "New York", "Texas", "Washington", "California" };

            var storeLocation = "";
            int storeId       = 0;
            while (true)
            {
                Console.Write("Please choose a store location to place the order from\n");
                Console.WriteLine("\nPress 1 for Florida\nPress 2 for New York\nPress 3 for Texas\nPress 4 for Washington\nPress 5 for California\n");
                Console.Write("Enter your choice: ");
                storeLocation = Console.ReadLine();
                if (storeLocation == "1" || storeLocation == "2" || storeLocation == "3" || storeLocation == "4" || storeLocation == "5")
                {
                    storeId = ParseString.ToInt(storeLocation);
                    if (storeId == 0)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;  Console.WriteLine("Invalid input"); continue;
                    }
                    break;
                }
                continue;
            }
            #endregion StoreId setter

            #region Get All the products from Inventory By StoreId Set above and loop through and display those.
            var productService = Container.GetService <IProductRepository>();
            var result         = await productService.GetProductsByStoreAsync(storeId);

            // Create an empty dictionary
            Dictionary <int, int> dbValuePairs          = new Dictionary <int, int>();
            Dictionary <int, int> productIdQuantityPair = new Dictionary <int, int>();
            Dictionary <int, int> productCart           = new Dictionary <int, int>();
            List <string>         productNames          = new List <string>();

            int count = 0;
            Console.WriteLine($"Code*********Name*******Store****Quantity*****************************************");
            foreach (InventoryItem i in result)
            {
                count++;
                dbValuePairs.Add(i.ProductId, i.Quantity);
                // inititalize second dict with same key but with values 0
                productIdQuantityPair.Add(i.ProductId, 0);
                productNames.Add(i.Product.Name);
                Console.WriteLine($"{i.Product.ProductCode.PadRight(5)} \t{i.Product.Name.PadLeft(10)}  {i.Store.Name.PadLeft(10)} {i.Quantity.ToString().PadLeft(7)}");
            }
            #endregion


            #region Creates a Cart that holds the user inputted purchases for a time being.
            // Allow users to choose multiple products with multiple quantity.
            int  productCount    = productNames.Count;
            var  productCode     = "";
            int  userProductCode = 0;
            int  userQuantity    = 0;
            bool flag            = false;
            while (true)
            {
                Console.Write("\nEnter Product code of product to purchase: ");
                productCode = Console.ReadLine();

                Regex regex = new Regex(@"^[P][0]{4}[1-9]|10$");
                Match match = regex.Match(productCode);
                if (!match.Success)
                {
                    Console.WriteLine("Product code did not match: ");
                    continue;
                }
                else
                {
                    Console.WriteLine("Refer to the product inventory table above before entering amount\nYour purchase cannot exceed quantity available at the store\n");
                    Console.Write("Enter the amount you want to purchase: ");
                    var amount = Console.ReadLine();
                    userQuantity = ParseString.ToInt(amount);
                    if (userQuantity == 0)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Invalid input");
                        continue;
                    }
                    productCode     = productCode.Substring(4, 2);
                    userProductCode = ParseString.ToInt(productCode);

                    if (userQuantity != 0 || userProductCode != 0)
                    {
                        if (productCart.ContainsKey(userProductCode))
                        {
                            flag = true;
                        }

                        productIdQuantityPair[userProductCode] += userQuantity;
                        //Console.WriteLine($" added : {productIdQuantityPair[userProductCode]}");
                        foreach (var key in dbValuePairs.Keys)
                        {
                            if ((dbValuePairs[userProductCode] >= productIdQuantityPair[userProductCode]))
                            {
                                if (flag == false)
                                {
                                    productCart.Add(userProductCode, productIdQuantityPair[userProductCode]);
                                    //Console.WriteLine($"Added: { productIdQuantityPair[userProductCode]}");
                                    Console.WriteLine("\nProduct added to the cart successfully\n");
                                    flag = true;
                                    break;
                                }
                                else
                                {
                                    productCart[userProductCode] = productIdQuantityPair[userProductCode];
                                    Console.WriteLine("\nProduct added to the cart successfully\n");
                                    break;
                                }
                            }
                            else
                            {
                                Console.WriteLine("\nSorry cart cannot hold more items than that can be purchased...\n");
                                flag = false;
                                break;
                            }
                        }

                        flag = false;
                        Console.Write("\nDo you want to continue adding items to the cart?\n");
                        Console.Write("\nType \"yes\" if you want to continue, press any other key to go to the purchase menu: ");
                        var input = Console.ReadLine();
                        if (input.Trim().ToLower() == "yes")
                        {
                            continue;
                        }
                        break;
                    }

                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid Input"); continue;
                    }
                }
            }
            #endregion

            #region loops through the cart above and displays the list of choices by user.
            foreach (KeyValuePair <int, int> entry in productCart)
            {
                Console.WriteLine($"Your cart entries {productNames[entry.Key - 1]} {entry.Value}");
            }
            #endregion

            #region Asks for users confirmation for purchase. Displays total etc.
            while (true)
            {
                Console.Write("Do you want to purchase these products now ? \nType yes or no to confirm or deny on next prompt\n");
                Console.Write("Enter your choice: ");
                var confirmPurchase = Console.ReadLine();

                #region If confirmed by user we create the objects to be inserted.

                if (confirmPurchase.ToLower().Trim() == "yes")
                {
                    Console.WriteLine("Excellent!");
                    var   userId = SessionHolder.UserId;
                    Order order  = new Order
                    {
                        CustomerId = userId,
                        StoreId    = storeId,
                        OrderDate  = DateTimeOffset.Now.LocalDateTime
                    };

                    decimal total = 0.0M;
                    count = 0;

                    var products = await productService.GetAllProductsAsync();

                    List <OrderLineItem> orderLineItems = new List <OrderLineItem>();
                    Console.WriteLine("****************************Billing********************");
                    foreach (KeyValuePair <int, int> entry in productCart)
                    {
                        foreach (Product i in products)
                        {
                            if (i.Id == entry.Key)
                            {
                                count++;
                                orderLineItems.Add(
                                    new OrderLineItem
                                {
                                    Order           = order,
                                    InventoryItemId = entry.Key,
                                    Quantity        = entry.Value,
                                    Price           = 150.55M
                                });
                                Console.WriteLine($"{count}. {productNames[entry.Key - 1]} {entry.Value} {i.Price}");
                                total += entry.Value * i.Price;
                            }
                        }
                    }
                    Console.WriteLine($"The total amount of purchase is : ${total}");
                    order.OrderLineItems = orderLineItems;
                    var createOrder = Container.GetService <IOrderService>();
                    await createOrder.CreateOrder(order);

                    Console.WriteLine("Order dispatched");
                    return;
                }

                #endregion

                #region If not confirmed say bye bye!
                else if (confirmPurchase.ToLower().Trim() == "no")
                {
                    Console.WriteLine("Nice meeting ya, please come again later...");
                    return;
                }
                #endregion
                else
                {
                    continue;
                }
            }
            #endregion
        }