Beispiel #1
0
        /// <summary>
        /// Choose menu "Change user data"
        /// </summary>
        public static void ChangeUserDataByAdmin()
        {
            string inputName, inputUserId;
            int    userId;

            Print.PrintHeader("Change user data", ConsoleColor.DarkYellow);
            inputUserId = Print.ReadInput("Enter user ID:");

            userId = ParseInput.IsCorrectId(inputUserId);
            if (userId == -1)
            {
                return;
            }

            inputName = Print.ReadInput("Enter new user name (at least 3 characters):");
            if (!ParseInput.IsCorrectName(inputName))
            {
                return;
            }

            if (!StartActions.AdminLogic.ChangeUserName(inputName, userId))
            {
                Console.WriteLine("Username hasn't changed!");
            }
            else
            {
                Console.WriteLine("Username has changed!");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Choose menu "Receiving Order"
        /// </summary>
        public static void ReceivingOrder()
        {
            string inputOrderId;
            int    orderId;

            Print.PrintHeader("Receiving Order", ConsoleColor.DarkYellow);

            inputOrderId = Print.ReadInput("Enter order ID:");

            orderId = ParseInput.IsCorrectId(inputOrderId);

            if (orderId == -1)
            {
                return;
            }

            if (!StartActions.UserLogic.ReceivingOrder(orderId))
            {
                Console.WriteLine("\nSuch order doesn't exist!");
            }
            else
            {
                Console.WriteLine("\nOrder received!");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Choose menu "Change order status"
        /// </summary>
        public static void ChangeStatus()
        {
            string inputUserId, inputOrderId;
            int    userId, orderId;

            Print.PrintHeader("Change order status", ConsoleColor.DarkYellow);

            inputUserId = Print.ReadInput("\nEnter user ID: ");
            userId      = ParseInput.IsCorrectId(inputUserId);
            if (userId == -1)
            {
                return;
            }

            inputOrderId = Print.ReadInput("\nEnter order ID: ");
            orderId      = ParseInput.IsCorrectId(inputOrderId);
            if (orderId == -1)
            {
                return;
            }

            if (!StartActions.AdminLogic.UserExist(userId))
            {
                Console.WriteLine("Such user doesn't exist!");
                return;
            }

            if (!StartActions.AdminLogic.OrderExist(userId, orderId))
            {
                Console.WriteLine("Such order doesn't exist!");
                return;
            }

            Console.WriteLine("Choose status: ");

            foreach (var item in StartActions.AdminLogic.GetStatuses())
            {
                Console.WriteLine(item);
            }

            string inputStatus = Print.ReadInput("\nEnter status number: ");

            if (!StartActions.AdminLogic.ChangeStatus(userId, orderId, inputStatus))
            {
                Console.WriteLine("Incorrect input status!");
            }
            else
            {
                Console.WriteLine("Status changed!");
            }
        }
Beispiel #4
0
        /// <summary>
        /// Choose menu "Add to shopping cart"
        /// </summary>
        public static void AddToShoppingCart()
        {
            string inputProductId;
            int    productId;

            Print.PrintHeader("Add to shopping cart", ConsoleColor.DarkYellow);

            inputProductId = Print.ReadInput("\nEnter ID of the product you want to add to the cart: ");
            productId      = ParseInput.IsCorrectId(inputProductId);

            if (productId == -1)
            {
                return;
            }

            if (!StartActions.UserLogic.AddToShoppingCart(productId))
            {
                Console.WriteLine("\nSuch product doesn't exist!");
            }
            else
            {
                Console.WriteLine($"\nProduct with ID:{productId} added!");
            }
        }
Beispiel #5
0
        /// <summary>
        /// Choose menu "Remove from shopping cart"
        /// </summary>
        public static void RemoveFromShoppingCart()
        {
            string inputProductId;
            int    productId;

            Print.PrintHeader("Remove from shopping cart", ConsoleColor.DarkYellow);

            inputProductId = Print.ReadInput("\nEnter ID of the product you want to remove from the cart: ");
            productId      = ParseInput.IsCorrectId(inputProductId);

            if (productId == -1)
            {
                return;
            }

            if (!StartActions.UserLogic.RemoveFromShoppingCart(productId))
            {
                Console.WriteLine("\nThis product is not in the cart!");
            }
            else
            {
                Console.WriteLine($"\nProduct with ID:{productId} removed!");
            }
        }
Beispiel #6
0
        /// <summary>
        /// Choose menu "Change product data"
        /// </summary>
        public static void ChangeProductDataByAdmin()
        {
            string  inputName, inputPrice, inputProductId;
            int     productId;
            decimal price;

            Print.PrintHeader("Change product data", ConsoleColor.DarkYellow);

            inputProductId = Print.ReadInput("Enter product ID:");
            productId      = ParseInput.IsCorrectId(inputProductId);
            if (productId == -1)
            {
                return;
            }

            if (!StartActions.AdminLogic.ProductExist(productId))
            {
                Console.WriteLine("Such product doesn't exist!");
                return;
            }

            string input = Print.ReadInput("Enter what you need to change\n[1] Product name\n[2] Product price");

            if (input == "1")
            {
                inputName = Print.ReadInput("Enter new name:");
                if (!ParseInput.IsCorrectName(inputName))
                {
                    return;
                }

                if (StartActions.AdminLogic.ChangeProductName(productId, inputName))
                {
                    Console.WriteLine("Name changed!");
                }
                else
                {
                    Console.WriteLine("Incorrect input!");
                }
            }
            else if (input == "2")
            {
                inputPrice = Print.ReadInput("Enter new price:");
                price      = ParseInput.IsCorrectPrice(inputPrice);

                if (price == -1)
                {
                    return;
                }

                if (StartActions.AdminLogic.ChangeProductPrice(productId, price))
                {
                    Console.WriteLine("Price changed!");
                }
                else
                {
                    Console.WriteLine("Incorrect input!");
                }
            }
            else
            {
                Console.WriteLine("Incorrect input!");
            }
        }