Ejemplo n.º 1
0
        public void HistoryInitiator(string phone)
        {
            order.Clear();
            dates.Clear();
            string       Line = "";
            StreamReader sr   = new StreamReader("OrderHistory.txt"); //Setup of txt = TelephoneNumber;OrderContent;TotalPrice

            while (sr.EndOfStream == false)
            {
                Line = sr.ReadLine();

                string[] Initiate = Line.Split(';'); //This splits the txt file single lines in strings
                if (Initiate[0] == phone)
                {
                    Pinsa Date = new Pinsa();
                    Date.Date  = Initiate[Initiate.Length - 1];
                    Date.Price = int.Parse(Initiate[Initiate.Length - 2]);
                    Dates.Add(Date);
                    for (int i = 1; i < Initiate.Length - 2; i++)
                    {
                        Pinsa orderHistory = new Pinsa(); //Makes a new instance of the customer. Make sure that the txt file is correctly made or we will get expections here.
                        orderHistory.Date = Initiate[Initiate.Length - 1];
                        orderHistory.Name = Initiate[i];
                        Order.Add(orderHistory); //Adds the create instance to the customers list
                    }
                }
            }
            sr.Close();
        }
Ejemplo n.º 2
0
        public OrderViewModel(Item item)
        {
            Pinsa i = (Pinsa)item;

            Name  = i.Name;
            Price = i.Price;
        }
Ejemplo n.º 3
0
        public HistoryViewModel(Item dateOrHistory)
        {
            Pinsa p = (Pinsa)dateOrHistory;

            Date  = p.Date;
            Name  = p.Name;
            Price = p.Price;
        }
Ejemplo n.º 4
0
 public void AcceptOrderWithBonus(string number)
 {
     foreach (OrderViewModel item in OrderList)
     {
         Pinsa tempItem = new Pinsa();
         tempItem.Name  = item.Name;
         tempItem.Price = item.Price;
         or.Order.Add(tempItem);
     }
     (int totalPriceWithBonus, double loyaltyPointsReturned) = or.WriteToOrderHistoryWithBonus(
         SelectedCustomer.Phone.ToString(), SelectedCustomer.LoyaltyPoints);
     AddLPFromOrder(SelectedCustomer.Phone, totalPriceWithBonus, loyaltyPointsReturned);
 }
Ejemplo n.º 5
0
        public void AcceptOrder(string number)
        {
            foreach (OrderViewModel item in OrderList)
            {
                Pinsa tempItem = new Pinsa();
                tempItem.Name  = item.Name;
                tempItem.Price = item.Price;
                or.Order.Add(tempItem);
            }
            int totalPrice = or.WriteToOrderHistory(SelectedCustomer.Phone.ToString());

            AddLPFromOrder(SelectedCustomer.Phone, totalPrice);
        }
Ejemplo n.º 6
0
        public void MenuListInitiator()
        {
            StreamReader sr = new StreamReader("MenuItems.txt");

            while (sr.EndOfStream == false)
            {
                string   Line  = sr.ReadLine();
                string[] Lines = Line.Split(';');
                Pinsa    pinsa = new Pinsa();
                pinsa.Name  = Lines[0];
                pinsa.Price = int.Parse(Lines[1]);
                menuList.Add(pinsa);
            }
            sr.Close();
        }
Ejemplo n.º 7
0
        public void ShowChosenDate()
        {
            if (SelectedDate != null)
            {
                NameList.Clear();

                Pinsa pricePinsa = new Pinsa()
                {
                    Name = "Total Price: " + SelectedDate.Price.ToString()
                };                                                                                         //Total Price is made like a Pinsa so it can be shown on the list together with the other "Real" pinsas
                hvm = new HistoryViewModel(pricePinsa);
                NameList.Add(hvm);

                foreach (Pinsa pinsa in or.Order)
                {
                    if (SelectedDate.Date == pinsa.Date)
                    {
                        hvm = new HistoryViewModel(pinsa);
                        NameList.Add(hvm);
                    }
                }
            }
        }