public static bool CxAlreadyExistsChecker(Abstractions.IRepositoryCustomer <Customer1> repo, string email, string phone) { var customers = repo.ReadInCustomer(); foreach (var Cx in customers) { if (Cx.Email != null && Cx.Email.Equals(email)) { if (Cx.Phone.Equals(phone)) { return(true); } } } return(false); }
public static string LoginUserPrompter(Abstractions.IRepositoryCustomer <Customer1> repo) { var customers = repo.ReadInCustomer(); string email = EmailCheck.NewEmailChecker(); if (email.Equals("quit")) { return("@"); } string password = PassCheck.NewPassChecker(); if (password.Equals("quit")) { return("@"); } string name = ""; bool correctAuth = false; foreach (var Cx in customers) { if (Cx.Email != null && Cx.Email.Equals(email)) { if (Cx.UserPass.Equals(password)) { name = Cx.Fname; correctAuth = true; } } } if (!correctAuth) { Console.Clear(); Console.WriteLine("No User found with that email and password."); Thread.Sleep(1000); return("@"); } return(name); }
/// <summary> /// Choose Pizza Location /// </summary> /// <param name="username"></param> /// <param name="stores"></param> public static void choosePizzaStoreLocation(string username, Abstractions.IRepositoryCustomer <Customer1> repo, Abstractions.IRepositoryOrders <Order1> orderRepo, Abstractions.IRepositoryPizza <Pizza1> pizzaRepo, Abstractions.IRepositoryStore <Store1> storeRepo) { var customer = repo.ReadInCustomer(); var order = orderRepo.ReadInOrder(); var pizza = pizzaRepo.ReadInPizza(); var store = storeRepo.ReadInStore(); int locationChoice = -1; while (locationChoice != 0) { Console.Clear(); Console.WriteLine(" __________________________________________________________"); Console.WriteLine(" | Hello:\t[" + username + "]"); Console.WriteLine(" |---------------------------------------------------------"); Console.WriteLine(" | Select a Pizza Parlor Location"); Console.WriteLine(" |_________________________________________________________"); // read through the list of Pizza parlors available. Dictionary <int, int> LocChoice = new Dictionary <int, int>(); int storeCount = 0; foreach (var s in store) { //DateTimeLogic.MostRecentOrder.getMostRecentOrder(store, customer, order, username); // var cx = customer.OrderByDescending(Cx => Cx.Fname != null && Cx.Fname.Equals(username)); var Cus = customer.FirstOrDefault(Cx => Cx.Fname.Equals(username)); DateTime dt = DateTime.Now; double time = 25; double date2 = 25; // For each order go through and check if store id and customer id match foreach (var Ord in order) { if (Cus.Id == Ord.CustId && Ord.StoreId == s.Id) { TimeSpan ts2 = (TimeSpan)(dt - Ord.OrderDate); date2 = ts2.TotalMinutes / 60; if (date2 < time) { time = date2; } } } if (time >= 24) { //Console.WriteLine($"Yes visited and time {time}hrs ago"); storeCount++; Console.WriteLine($" |{storeCount}. : {s.StoreName}"); Console.WriteLine($" | {s.StoreLocation}"); Console.WriteLine(" |"); LocChoice.Add(storeCount, s.Id); } else { Console.WriteLine($" | Plese wait 24 hours before ordering from \"{s.StoreName}\" again."); Console.WriteLine($" | \t - You have {Math.Round((24 - time), 2)} hours remaining."); Console.WriteLine(" |"); } } Console.WriteLine(" |0. : Return to previous page."); Console.WriteLine(" |_________________________________________________________"); locationChoice = IntCheck.IntChecker(); if (locationChoice == -1) { continue; } // choose location and bring up data about that location if (locationChoice > 0 && locationChoice <= storeCount) { var Loc = store.FirstOrDefault(S => S.Id == LocChoice[locationChoice]); // Call Main logic for In Store. _d_StorePortal.inStoreLogic(username, Loc.StoreName, repo, orderRepo, pizzaRepo, storeRepo); } if (locationChoice == 0) { Console.WriteLine("returning to the previous page..."); Thread.Sleep(500); break; } } }
public static void DisplayOrderHistory(string username, Abstractions.IRepositoryCustomer <Customer1> repo, Abstractions.IRepositoryPizza <Pizza1> pizzaRepo, Abstractions.IRepositoryOrders <Order1> orderRepo ) { var customer = repo.ReadInCustomer(); var order = orderRepo.ReadInOrder(); var pizza = pizzaRepo.ReadInPizza(); BitFlagConversion BFC = new BitFlagConversion(); Console.Clear(); Console.WriteLine(" ____________________________________________________________________________"); Console.WriteLine(" | Hello:\t[" + username + "]"); Console.WriteLine(" |---------------------------------------------------------------------------"); Console.WriteLine(" | ... Order history ..."); var Cus = customer.FirstOrDefault(Cx => Cx.Fname.Equals(username)); var ORD = order.OrderByDescending(o => o.OrderDate); foreach (var Ord in ORD) //foreach (var Ord in order.OrderByDescending) { int inOrder = 0; foreach (var pie in pizza) { if (Cus.Id == Ord.CustId && pie.OrderId == Ord.OrderId) { if (inOrder != pie.OrderId) { Console.WriteLine(" |---------------------------------------------------------------------------"); Console.WriteLine($" | Order: {Ord.OrderId} on Date {Ord.OrderDate} Total Cost ${Ord.Price}"); } Console.Write($" | ${pie.Price} :: {pie.Size}inch {pie.Crust} "); char[] tops = BFC.convertIntToFlagArray(pie.Toppings, 5); if (tops[0] == '1') { Console.Write(" <sauce> "); } if (tops[1] == '1') { Console.Write(" <cheese> "); } if (tops[2] == '1') { Console.Write(" <pepperoni> "); } if (tops[3] == '1') { Console.Write(" <sausage> "); } if (tops[4] == '1') { Console.Write(" <pineapple> "); } Console.WriteLine(); inOrder = pie.OrderId; } } } Console.WriteLine(" |___________________________________________________________________________"); Console.WriteLine("...Press Any Key To Continue."); Console.ReadLine(); }
/// <summary> /// Main Logic for initial choices a Cx can make when they login to the store /// </summary> /// <param name="username"></param> /// <param name="stores"></param> /// <param name="locationChoice"></param> /// <param name="CurOrd"></param> /// <param name="LocationOrderHistory"></param> public static void inStoreLogic(string username, string storeName, Abstractions.IRepositoryCustomer <Customer1> repo, Abstractions.IRepositoryOrders <Order1> orderRepo, Abstractions.IRepositoryPizza <Pizza1> pizzaRepo, Abstractions.IRepositoryStore <Store1> storeRepo) { var customer = repo.ReadInCustomer(); var order = orderRepo.ReadInOrder(); var pizza = pizzaRepo.ReadInPizza(); var store = storeRepo.ReadInStore(); // Create new order object to temporarily store the order before confirming it. CurrentOrder curOrder = new CurrentOrder(); int inStoreChoice = -1; while (inStoreChoice != 0) { ZZ_PrintLoggedInHeader.printStoreHeaderLoggedIn(username, storeName); Console.WriteLine(" |---------------------------------------------------------"); Console.WriteLine(" | 1. : Order a Pizza."); Console.WriteLine(" | 2. : Preview Your Current Order."); Console.WriteLine(" | 3. : [ADMIN] Preview All Orders at this Location."); Console.WriteLine(" | 0. : Return to Restaurant choice."); Console.WriteLine(" |_________________________________________________________"); inStoreChoice = IntCheck.IntChecker(); if (inStoreChoice == -1) { continue; } // Pizza Size if (inStoreChoice == 1) { _e_PizzaMakeChoice.pizzaMakerChoice(username, storeName, curOrder); } if (inStoreChoice == 2) { if (curOrder.pizzasInOrder.Count == 0) { Console.Clear(); Console.WriteLine("No pizza's ordered yet!"); Thread.Sleep(500); } else { inStoreChoice = 0; // trying to for customer back to store choice after checking out a pizza. // Ordering.CxCurrentOrder.getCustCurrentOrder(username, storeName, curOrder, customer); int num = CxOrdersAtLocation.printCxPrevOrdersAtCurrLoc(username, storeName, curOrder); if (num == 1) // try to read int choice { // Randomize and create new order. Random random = new Random(); int OrderID = random.Next(1000000000, 2000000000); var cx = customer.FirstOrDefault(Cx => Cx.Fname != null && Cx.Fname.Equals(username)); var stor = store.FirstOrDefault(S => S.StoreName.Equals(storeName)); // Tally the complete order first to get the total. double total = 0; foreach (var pi in curOrder.pizzasInOrder) { total += pi.getPriceOfPizza(); } // Create new order and submit. Order1 Or = new Order1() { CustId = cx.Id, OrderId = OrderID, StoreId = stor.Id, Price = (decimal)total }; orderRepo.CreateOrder(Or); foreach (var pie in curOrder.pizzasInOrder) { // char [] tops = Ordering.AddToppingsToPie.getAddToppingsToPie(pie); // Convert toppings int a singular decimal representing a bit flag int topSet = BitFlagConversion.convertFlagArrayToInt(tops); Pizza1 Cu = new Pizza1() { PizzaId = random.Next(1000000000, 2000000000), Toppings = topSet, Crust = pie.getCrustChoice(), Size = pie.getSizeChoice(), OrderId = OrderID, Price = (decimal)pie.getPriceOfPizza() }; pizzaRepo.CreatePizza(Cu); } } } } // Look at previous order history at current location if (inStoreChoice == 3) { Ordering.RestaurantOrdersEmployee.AllRestaurantOrders(orderRepo, storeRepo, username, storeName); } if (inStoreChoice == 0) { Console.WriteLine("returning to the previous page..."); Thread.Sleep(700); break; } } }