Пример #1
0
        public static void Customer(List <Plagg> store, List <Plagg> purchase)
        {
            List <string> menyChoice = new List <string>();
            string        s1         = "|  Visa varukorg.  |\n" +
                                       "|------------------|";

            menyChoice.Add(s1);
            string s2 = "|  Handla.         |\n" +
                        "|------------------|";

            menyChoice.Add(s2);
            string s3 = "";

            int Choice = NavigateMeny.NavigateStringList(menyChoice);

            if (Choice == 0)
            {
                Console.Clear();
                if (purchase.Count != 0)
                {
                    foreach (var plagg in purchase)
                    {
                        Console.WriteLine($"Typ av plagg: {plagg.Type}\nFärg: {plagg.Colour}" +
                                          $"\nStorlek: {plagg.Size}\nPris: {plagg.Price}");
                        Console.WriteLine("-------------------------------");
                    }
                    Console.WriteLine($"Det finns {purchase.Count} varor i din varukorg.");
                    Console.ReadLine();
                    Payment(purchase);
                    //.ReadLine();
                }
                else
                {
                    Console.Clear();

                    Console.WriteLine("Din varukorg är tom.");
                    Console.ReadLine();
                }
            }
            if (Choice == 1)
            {
                Console.Clear();
                if (store.Count != 0)
                {
                    Purchase(store, purchase);
                }
                else
                {
                    Console.WriteLine("Butiken är tom.");
                    Console.ReadLine();
                }
            }
        }
Пример #2
0
        public static void Payment(List <Plagg> purchase)
        {
            List <string> menyChoice = new List <string>();
            string        s1         = "Gå till Betalning.";
            string        s2         = "Ta bort en vara.";
            string        s3         = "Bakåt.";

            menyChoice.Add(s1);
            menyChoice.Add(s2);
            menyChoice.Add(s3);

            int choice = NavigateMeny.NavigateStringList(menyChoice);

            if (choice == 0)
            {
                Console.Clear();
                int sum = 0;
                foreach (var item in purchase)
                {
                    sum += item.Price;
                }
                Console.WriteLine($"Summa: {sum}");
                Console.WriteLine("Tack för di betalning! ");
                Console.ReadKey();
                purchase.Clear();
            }
            if (choice == 1)
            {
                int remove = NavigateMeny.NavigatePlaggList(purchase);
                int count  = 0;
                foreach (var item in purchase)
                {
                    count++;

                    if (remove == count)
                    {
                        purchase.RemoveAt(count - 1);
                        break;
                    }
                }
            }
            if (choice == 2)
            {
            }
        }
Пример #3
0
        public static int Meny()
        {
            List <string> menyCoice = new List <string>();

            string s1 = "|  Logga in som Admin       |\n" +
                        "|---------------------------|";

            menyCoice.Add(s1);
            string s2 = "|  Logga in som kund        |\n" +
                        "|---------------------------|";

            menyCoice.Add(s2);
            string s3 = "|   Avsluta                 |\n" +
                        "|---------------------------|";

            menyCoice.Add(s3);

            int choice = NavigateMeny.NavigateStringList(menyCoice);

            return(choice);
        }
Пример #4
0
        public static void Purchase(List <Plagg> store, List <Plagg> purchase)
        {
            int  scroll = 1;
            bool done   = false;

            while (!done)
            {
                int counter = 1;
                Console.Clear();
                foreach (var plagg in store)
                {
                    if (counter == scroll)
                    {
                        Console.BackgroundColor = ConsoleColor.Green;
                        Console.WriteLine($"Typ av plagg: {plagg.Type}\nFärg: {plagg.Colour}" +
                                          $"\nStorlek: {plagg.Size}\nPris: {plagg.Price}");
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.WriteLine("-------------------------------");
                    }
                    else
                    {
                        Console.WriteLine($"Typ av plagg: {plagg.Type}\nFärg: {plagg.Colour}" +
                                          $"\nStorlek: {plagg.Size}\nPris: {plagg.Price}");
                        Console.WriteLine("-------------------------------");
                    }
                    counter++;
                }

                ConsoleKey key = Console.ReadKey().Key;
                if (key == ConsoleKey.A && scroll == store.Count)
                {
                    scroll = store.Count;
                }
                else if (key == ConsoleKey.Z && scroll == 1)
                {
                    scroll = 1;
                }

                else if (key == ConsoleKey.A)
                {
                    scroll++;
                }
                else if (key == ConsoleKey.Z)
                {
                    scroll--;
                }
                else if (key == ConsoleKey.Enter)
                {
                    Console.Clear();
                    var plagg = store[scroll - 1];
                    purchase.Add(plagg);
                    Console.WriteLine("Varan ligger nu i din varukorg!");
                    List <string> menyChoice = new List <string>();
                    string        s1         = "|       Fortsätt handla.        |\n" +
                                               "|-------------------------------|";
                    menyChoice.Add(s1);
                    string s2 = "|       Klar.                   |\n" +
                                "|-------------------------------|";
                    menyChoice.Add(s2);
                    int choice = NavigateMeny.NavigateStringList(menyChoice);

                    if (choice == 0)
                    {
                        done = false;
                    }
                    else if (choice == 1)
                    {
                        done = true;
                    }
                }
            }
        }
Пример #5
0
        public static void Admin(List <Plagg> store)
        {
            bool done = false;

            while (!done)
            {
                try
                {
                    List <String> menyChoice = new List <string>();
                    string        s1         = "|Lägg till ett plagg|\n" +
                                               "|-------------------|";
                    menyChoice.Add(s1);
                    string s2 = "|Visa sortiment     |\n" +
                                "|-------------------|";
                    menyChoice.Add(s2);
                    string s3 = "|Klar               |\n" +
                                "|-------------------|";
                    menyChoice.Add(s3);

                    int choice = NavigateMeny.NavigateStringList(menyChoice);

                    if (choice == 0)
                    {
                        Console.Clear();
                        AddCloth(store);
                    }
                    if (choice == 1)
                    {
                        Console.Clear();
                        foreach (var plagg in store)
                        {
                            Console.WriteLine($"Typ av plagg: {plagg.Type}\nFärg: {plagg.Colour}" +
                                              $"\nStorlek: {plagg.Size}\nPris: {plagg.Price}");
                            Console.WriteLine("-------------------------------");
                        }
                        Console.ReadLine();
                        List <string> menyChoice2 = new List <string>();
                        string        s4          = "Rensa sortiment.";
                        string        s5          = "Ta bort ett plagg.";
                        string        s6          = "Klar";
                        menyChoice2.Add(s4);
                        menyChoice2.Add(s5);
                        menyChoice2.Add(s6);
                        int choice2 = NavigateMeny.NavigateStringList(menyChoice2);
                        if (choice2 == 0)
                        {
                            store.Clear();
                        }
                        if (choice2 == 1)
                        {
                        }
                        if (choice2 == 2)
                        {
                        }
                    }
                    if (choice == 2)
                    {
                        done = true;
                        SaveStore(store);
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Ogiltig inmatning, försök igen...");
                    Console.ReadLine();
                }
                Console.Clear();
            }
        }