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(); }
public OrderViewModel(Item item) { Pinsa i = (Pinsa)item; Name = i.Name; Price = i.Price; }
public HistoryViewModel(Item dateOrHistory) { Pinsa p = (Pinsa)dateOrHistory; Date = p.Date; Name = p.Name; Price = p.Price; }
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); }
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); }
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(); }
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); } } } }