Beispiel #1
0
        public void ChooseCategoryAction(ClothesShopContext db)
        {
            Console.WriteLine();
            Console.WriteLine("Please choose your action:");
            Console.WriteLine("1 - View Item");
            Console.WriteLine("2 - Back to Categories");
            Console.WriteLine("3 - Back to HomePage");

            int choice = GeneralStaticClass.ReadIntNumber();

            while (choice != 1 && choice != 2 && choice != 3)
            {
                Console.WriteLine("There is no such choice");
                choice = GeneralStaticClass.ReadIntNumber();
            }
            switch (choice)
            {
            case 1:
                BuyingClothes.ShowItem(db);
                break;

            case 2:
                BuyingClothes.ShowCategories(db);
                break;

            case 3:
                Console.Clear();
                BuyingClothes.ShowHome(db);
                break;

            default:
                Console.WriteLine("There is no such choice");
                break;
            }
        }
Beispiel #2
0
        public void ChooseUserActions(ClothesShopContext db)
        {
            Console.WriteLine("Please choose your action:");
            Console.WriteLine("1 - User Information");
            Console.WriteLine("2 - Home Page");
            int choice = GeneralStaticClass.ReadIntNumber();

            while (choice != 1 && choice != 2)
            {
                Console.WriteLine("Invalid choice");
                choice = GeneralStaticClass.ReadIntNumber();
            }
            if (choice == 1)
            {
                Console.Clear();
                BuyingClothes.User.ShowUserInfo(db);
                Console.WriteLine();
                Console.WriteLine("Back to Home Page? Y/N");

                if (Console.ReadLine().ToUpper() == "Y")
                {
                    Console.Clear();
                    BuyingClothes.ShowHome(db);
                }
            }
            else
            {
                Console.Clear();
                BuyingClothes.ShowHome(db);
            }
        }
Beispiel #3
0
        public void ChooseEmptyBasketAction(ClothesShopContext db)
        {
            Console.WriteLine();
            Console.WriteLine("Please choose your action:");
            Console.WriteLine("1 - Back to Item View");
            Console.WriteLine("2 - Back to HomePage");
            int choice = GeneralStaticClass.ReadIntNumber();

            while (choice != 1 && choice != 2)
            {
                Console.WriteLine("There is no such choice");
                choice = GeneralStaticClass.ReadIntNumber();
            }
            switch (choice)
            {
            case 1:
                Console.Clear();
                BuyingClothes.View.ShowItem(db);
                ChooseItemAction(db);
                break;

            case 2:
                Console.Clear();
                BuyingClothes.ShowHome(db);
                break;

            default:
                Console.WriteLine("There is no such choice");
                break;
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var shop = new BuyingClothes();

            shop.PurchaceClothes();

            GeneralStaticClass.ExitApp();
        }
Beispiel #5
0
        public void AskUserItemChoice()
        {
            Console.WriteLine();
            Console.WriteLine("Please write ID to view the item");
            ItemId = GeneralStaticClass.ReadIntNumber();

            while (!ItemIds.Contains(ItemId))
            {
                Console.WriteLine("Invalid choice");
                ItemId = GeneralStaticClass.ReadIntNumber();
            }
        }
Beispiel #6
0
        public void AskUserTypeChoice()
        {
            Console.WriteLine();
            Console.WriteLine("Please choose the type");
            int typeNumber = GeneralStaticClass.ReadIntNumber();

            while (!CheckTypeValidity(typeNumber))
            {
                Console.WriteLine("Invalid choice");
                typeNumber = GeneralStaticClass.ReadIntNumber();
            }
        }
Beispiel #7
0
        public void ChooseItemAction(ClothesShopContext db)
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Please choose your action:");
            Console.WriteLine("1 - Add Item to Basket");
            Console.WriteLine("2 - Go to Basket");
            Console.WriteLine("3 - Back to Category Items");
            Console.WriteLine("4 - Back to HomePage");

            int choice = GeneralStaticClass.ReadIntNumber();

            while (choice != 1 && choice != 2 && choice != 3 && choice != 4)
            {
                Console.WriteLine("There is no such choice");
                choice = GeneralStaticClass.ReadIntNumber();
            }
            switch (choice)
            {
            case 1:
                BuyingClothes.Basket.ChooseSizeQuantity(db, BuyingClothes.View.ItemId);
                if (BuyingClothes.Basket.Quantity == 0)
                {
                    BuyingClothes.View.ShowItem(db);
                    ChooseItemAction(db);
                }
                else
                {
                    BuyingClothes.Basket.AddItemToBasket(db, BuyingClothes.View.ItemId);
                    ChooseItemActionAfterAddingToBasket(db);
                }
                break;

            case 2:
                BuyingClothes.ShowBasket(db);
                break;

            case 3:
                BuyingClothes.View.ShowClothingCategoryItems(db);
                ChooseCategoryAction(db);
                break;

            case 4:
                Console.Clear();
                BuyingClothes.ShowHome(db);
                break;

            default:
                Console.WriteLine("There is no such choice");
                break;
            }
        }
Beispiel #8
0
        public int AskUserCategoryChoice()
        {
            Console.WriteLine();
            Console.WriteLine("Please choose the category");
            int categoryNumber = GeneralStaticClass.ReadIntNumber();

            while (!CheckCategoryValidity(categoryNumber) && categoryNumber != Categories.Count() + 1)
            {
                Console.WriteLine("Invalid choice");
                categoryNumber = GeneralStaticClass.ReadIntNumber();
            }
            return(categoryNumber);
        }
Beispiel #9
0
        public int GetItemToUpdateNo()
        {
            Console.WriteLine("Please provide the item number for updating");
            int itemToUpdate = GeneralStaticClass.ReadIntNumber();

            while (BasketItems.Count() < itemToUpdate || itemToUpdate <= 0)
            {
                Console.WriteLine("Invalid choice");
                itemToUpdate = GeneralStaticClass.ReadIntNumber();
            }
            Console.WriteLine(itemToUpdate--);
            return(itemToUpdate--);
        }
Beispiel #10
0
        public void ChooseFullBasketAction(ClothesShopContext db)
        {
            Console.WriteLine();
            Console.WriteLine("Please choose your action:");
            Console.WriteLine("1 - Proceed to Checkout");
            Console.WriteLine("2 - Update Basket Item");
            Console.WriteLine("3 - Delete Basket Item(s)");
            Console.WriteLine("4 - Back to Item View");
            Console.WriteLine("5 - Back to HomePage");

            int choice = GeneralStaticClass.ReadIntNumber();

            while (choice != 1 && choice != 2 && choice != 3 && choice != 4 && choice != 5)
            {
                Console.WriteLine("There is no such choice");
                choice = GeneralStaticClass.ReadIntNumber();
            }

            switch (choice)
            {
            case 1:
                BuyingClothes.Checkout(db);
                break;

            case 2:
                BuyingClothes.Basket.UpdateItem(db);
                Console.WriteLine("Basket updated");
                BuyingClothes.ShowBasket(db);
                break;

            case 3:
                BuyingClothes.Basket.DeleteItem();
                BuyingClothes.ShowBasket(db);
                break;

            case 4:
                Console.Clear();
                BuyingClothes.View.ShowItem(db);
                ChooseItemAction(db);
                break;

            case 5:
                Console.Clear();
                BuyingClothes.ShowHome(db);
                break;

            default:
                Console.WriteLine("There is no such choice");
                break;
            }
        }
Beispiel #11
0
        public void ChooseItemActionAfterAddingToBasket(ClothesShopContext db)
        {
            Console.WriteLine();
            Console.WriteLine("Please choose your action:");
            Console.WriteLine("1 - Go to Basket");
            Console.WriteLine("2 - Back to Item View");
            Console.WriteLine("3 - Back to Category View");
            Console.WriteLine("4 - Back to Home Page");

            int choice = GeneralStaticClass.ReadIntNumber();

            while (choice != 1 && choice != 2 && choice != 3 && choice != 4)
            {
                Console.WriteLine("There is no such choice");
                choice = GeneralStaticClass.ReadIntNumber();
            }

            switch (choice)
            {
            case 1:
                Console.Clear();
                BuyingClothes.ShowBasket(db);
                break;

            case 2:
                Console.Clear();
                BuyingClothes.View.ShowItem(db);
                ChooseItemAction(db);
                break;

            case 3:
                Console.Clear();
                BuyingClothes.ShowCategories(db);
                break;

            case 4:
                Console.Clear();
                BuyingClothes.ShowHome(db);
                break;

            default:
                Console.WriteLine("There is no such choice");
                break;
            }
        }
Beispiel #12
0
        public int GetNewItemQuantity(int itemToUpdate, ClothesShopContext db)
        {
            Console.WriteLine($"Updating item: {BasketItems[itemToUpdate].ClothingItem} ({BasketItems[itemToUpdate].Size})");
            var clothingItemToUpdate = BasketItems[itemToUpdate].ClothingItem;
            var sizeToUpdate         = BasketItems[itemToUpdate].Size;
            var dbClothingItemId     = db.ClothingItems.FirstOrDefault(c => c.Name == clothingItemToUpdate).ClothingItemId;
            var availableQuantity    = db.ClothingSizes.FirstOrDefault(a => a.ClothingItemId == dbClothingItemId && a.Size == sizeToUpdate).Quantity;

            Console.WriteLine($"Please provide new quantity. Total items available: {availableQuantity}");
            int newQuantity = GeneralStaticClass.ReadIntNumber();

            while (newQuantity < 0 || newQuantity > availableQuantity)
            {
                Console.WriteLine($"Invalid quantity. Total items available: {availableQuantity}");
                newQuantity = GeneralStaticClass.ReadIntNumber();
            }
            return(newQuantity);
        }
Beispiel #13
0
        public void CheckQuantityAvailability(string clothing, int availableQuantity)
        {
            Quantity = GeneralStaticClass.ReadIntNumber();
            foreach (var item in BasketItems)
            {
                while (item.ClothingItem == clothing && item.Size == Size && item.Quantity + Quantity > availableQuantity)
                {
                    Console.WriteLine($"Unavailable quantity. Quantity already in basket: {item.Quantity}");
                    Console.WriteLine("Type 0 to cancel");
                    Quantity = GeneralStaticClass.ReadIntNumber();
                }
            }

            while (Quantity > availableQuantity || Quantity < 0)
            {
                Console.WriteLine("Wrong quantity");
                Quantity = GeneralStaticClass.ReadIntNumber();
            }
        }
Beispiel #14
0
        public void ChooseStartingUserAction(ClothesShopContext db)
        {
            Console.WriteLine();
            Console.WriteLine("Please choose your action:");
            Console.WriteLine("1 - Log in");
            Console.WriteLine("2 - Register");
            Console.WriteLine("3 - Shop without registration");

            int choice = GeneralStaticClass.ReadIntNumber();

            while (choice != 1 && choice != 2 && choice != 3)
            {
                Console.WriteLine("There is no such choice");
                choice = GeneralStaticClass.ReadIntNumber();
            }

            switch (choice)
            {
            case 1:
                Console.Clear();
                BuyingClothes.User.LogIn(db);
                ChooseUserActions(db);
                break;

            case 2:
                Console.Clear();
                BuyingClothes.User.Register(db);
                Console.WriteLine("User registered, please log in");
                BuyingClothes.User.LogIn(db);
                ChooseUserActions(db);
                break;

            case 3:
                Console.Clear();
                BuyingClothes.User.SetUnregisteredShopping(db);
                BuyingClothes.ShowHome(db);
                break;

            default:
                Console.WriteLine("There is no such choice");
                break;
            }
        }
Beispiel #15
0
        public void DeleteItem()
        {
            Console.Clear();
            Console.WriteLine("BASKET VIEW");
            ShowBasket();
            Console.WriteLine();
            Console.WriteLine("Please provide the item number for deletion");
            Console.WriteLine($"To delete all items, write {BasketItems.Count() + 1}");
            int itemToDelete = GeneralStaticClass.ReadIntNumber();

            while (BasketItems.Count() + 1 < itemToDelete || itemToDelete < 0)
            {
                Console.WriteLine("Invalid choice");
                itemToDelete = GeneralStaticClass.ReadIntNumber();
            }
            if (itemToDelete == BasketItems.Count() + 1)
            {
                BasketItems.Clear();
            }
            else
            {
                BasketItems.RemoveAt(itemToDelete - 1);
            }
        }